GeezerVison is showing github.com — Merge branch '4.2' into socks5-private-auth-request-failure · netty/netty@7abefdc
File treeExpand file treeCollapse file tree Open diff view settings main/java/io/netty/buffer test/java/io/netty/buffer
codec-classes-quic/src/main/java/io/netty/handler/codec/quic main/java/io/netty/handler/codec/compression test/java/io/netty/handler/codec/compression
main/java/io/netty/handler/codec/dns test/java/io/netty/handler/codec/dns
main/java/io/netty/handler/codec/http2 test/java/io/netty/handler/codec/http2
main/java/io/netty/handler/codec test/java/io/netty/handler/codec
main/java/io/netty/handler/codec/mqtt test/java/io/netty/handler/codec/mqtt
codec-native-quic/src/test/java/io/netty/handler/codec/quic main/java/io/netty/handler/codec/smtp test/java/io/netty/handler/codec/smtp
templates/io/netty/util/collection
templates/io/netty/util/collection
main/java/io/netty/handler/ssl test/java/io/netty/handler/ssl
testsuite-jpms/src/test/java io/netty/testsuite_jpms/test
testsuite/src/main/java/io/netty/testsuite/transport/socket transport-classes-epoll/src/main/java/io/netty/channel/epoll transport-classes-io_uring/src/main/java/io/netty/channel/uring transport-classes-kqueue/src/main/java/io/netty/channel/kqueue transport-native-io_uring/src/test/java/io/netty/channel/uring transport-native-kqueue/src/test/java/io/netty/channel/kqueue transport-native-unix-common-tests/src/main/java/io/netty/channel/unix/tests transport-native-unix-common/src/main java/io/netty/channel/unix
main/java/io/netty/channel test/java/io/netty/channel
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +45-17Lines changed: 45 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | # Fork of https://github.com/AgentWorkforce/relay/blob/v12.2.2/.github/workflows/cancel-on-merge.yml | 2 | 2 | name: Cancel PR Jobs on Merge | | 3 | + | | 4 | +# We use pull_request_target (and not pull_request) as the GITHUB_TOKEN of a pull_request run triggered by a PR from | | 5 | +# a fork is read-only and so we would not be allowed to cancel anything. This is safe as this workflow never checks out | | 6 | +# or executes any code of the PR and only uses the event payload to look up the runs to cancel. | | 7 | +# | | 8 | +# Be aware that pull_request_target uses the workflow file of the base branch of the PR, so this file needs to exist | | 9 | +# on every branch we merge PRs into. | 3 | 10 | on: | 4 | | - pull_request: | | 11 | + pull_request_target: | 5 | 12 | types: [closed] | 6 | 13 |
| | 14 | +permissions: | | 15 | + actions: write # to cancel the workflow runs | | 16 | + | 7 | 17 | jobs: | 8 | 18 | cancel: | 9 | 19 | if: github.event.pull_request.merged == true | 10 | 20 | runs-on: ubuntu-latest | 11 | 21 | steps: | 12 | | - - name: Cancel running workflows for this PR | 13 | | - uses: actions/github-script@v7 | | 22 | + - name: Cancel running and queued workflows for this PR | | 23 | + uses: actions/github-script@v8 | 14 | 24 | with: | 15 | 25 | script: | | 16 | 26 | const { owner, repo } = context.repo; | 17 | | - const headSha = context.payload.pull_request.head.sha; | | 27 | + const pr = context.payload.pull_request; | 18 | 28 |
| 19 | | - // Get all running workflow runs for this commit | 20 | | - const runs = await github.rest.actions.listWorkflowRunsForRepo({ | | 29 | + // Everything that has not completed yet, which includes runs that are still waiting for a runner. | | 30 | + const active = new Set(['queued', 'in_progress', 'waiting', 'pending', 'requested']); | | 31 | +
| | 32 | + const runs = await github.paginate(github.rest.actions.listWorkflowRunsForRepo, { | 21 | 33 | owner, | 22 | 34 | repo, | 23 | | - status: 'in_progress', | 24 | | - head_sha: headSha, | | 35 | + head_sha: pr.head.sha, | | 36 | + per_page: 100, | 25 | 37 | }); | 26 | 38 |
| 27 | | - // Cancel each running workflow | 28 | | - for (const run of runs.data.workflow_runs) { | 29 | | - console.log(`Cancelling workflow run ${run.id} (${run.name})`); | 30 | | - await github.rest.actions.cancelWorkflowRun({ | 31 | | - owner, | 32 | | - repo, | 33 | | - run_id: run.id, | 34 | | - }); | | 39 | + let cancelled = 0; | | 40 | + for (const run of runs) { | | 41 | + if (!active.has(run.status) || run.id === context.runId) { | | 42 | + continue; | | 43 | + } | | 44 | + // Only touch runs triggered by the PR itself and not by a push to a branch that happens to point to | | 45 | + // the same commit. | | 46 | + if (run.event !== 'pull_request') { | | 47 | + continue; | | 48 | + } | | 49 | + // Runs of fork PRs have no pull_requests attached, for all others make sure the run does not belong | | 50 | + // to another PR that uses the same head commit (for example one targeting a different branch). | | 51 | + if (run.pull_requests.length > 0 && !run.pull_requests.some(p => p.number === pr.number)) { | | 52 | + continue; | | 53 | + } | | 54 | +
| | 55 | + console.log(`Cancelling workflow run ${run.id} (${run.name}, ${run.status})`); | | 56 | + try { | | 57 | + await github.rest.actions.cancelWorkflowRun({ owner, repo, run_id: run.id }); | | 58 | + cancelled++; | | 59 | + } catch (e) { | | 60 | + // Most likely the run completed in the meantime, there is nothing to free up in this case. | | 61 | + console.log(`Could not cancel workflow run ${run.id}: ${e.message}`); | | 62 | + } | 35 | 63 | } | 36 | 64 |
| 37 | | - console.log(`Cancelled ${runs.data.workflow_runs.length} workflow runs`); | | 65 | + console.log(`Cancelled ${cancelled} workflow runs`); |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/ci-pr-reports.yml +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,8 @@ concurrency: | 33 | 33 |
| 34 | 34 | jobs: | 35 | 35 | tests: | | 36 | + # Nothing to report if the run was cancelled, for example by cancel-on-merge.yml once the PR was merged. | | 37 | + if: github.event.workflow_run.conclusion != 'cancelled' | 36 | 38 | permissions: | 37 | 39 | actions: read # for dawidd6/action-download-artifact to query and download artifacts | 38 | 40 | checks: write # for scacap/action-surefire-report to publish result as PR check | |
Collapse file Copy file name to clipboardExpand all lines: bom/pom.xml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 89 | 89 | <plugin> | 90 | 90 | <groupId>org.sonatype.central</groupId> | 91 | 91 | <artifactId>central-publishing-maven-plugin</artifactId> | 92 | | - <version>0.7.0</version> | | 92 | + <version>0.12.0</version> | 93 | 93 | <configuration> | 94 | 94 | <publishingServerId>central</publishingServerId> | 95 | 95 | <skipPublishing>true</skipPublishing> | |
Collapse file Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/ByteBufUtil.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -252,7 +252,7 @@ public static int indexOf(ByteBuf needle, ByteBuf haystack) { | 252 | 252 | int n = haystack.readableBytes(); | 253 | 253 | int m = needle.readableBytes(); | 254 | 254 | if (m == 0) { | 255 | | - return 0; | | 255 | + return haystack.readerIndex(); | 256 | 256 | } | 257 | 257 |
| 258 | 258 | // When the needle has only one byte that can be read, | |
Collapse file Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/Unpooled.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -646,7 +646,7 @@ public static ByteBuf copiedBuffer( | 646 | 646 | } | 647 | 647 |
| 648 | 648 | buf = buf.slice(); | 649 | | - buf.limit(length); | | 649 | + buf.limit(offset + length); | 650 | 650 | buf.position(offset); | 651 | 651 | return copiedBuffer(buf, charset); | 652 | 652 | } | |
Collapse file Copy file name to clipboardExpand all lines: buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -196,6 +196,17 @@ public void testIndexOfNeedleWithReaderIndex() { | 196 | 196 | needle.release(); | 197 | 197 | } | 198 | 198 |
| | 199 | + @Test | | 200 | + public void testIndexOfEmptyNeedle() { | | 201 | + ByteBuf haystack = Unpooled.copiedBuffer("abc", CharsetUtil.US_ASCII); | | 202 | + assertEquals(0, ByteBufUtil.indexOf(Unpooled.EMPTY_BUFFER, haystack)); | | 203 | + haystack.readerIndex(1); | | 204 | + assertEquals(1, ByteBufUtil.indexOf(Unpooled.EMPTY_BUFFER, haystack)); | | 205 | + haystack.readerIndex(3); | | 206 | + assertEquals(3, ByteBufUtil.indexOf(Unpooled.EMPTY_BUFFER, haystack)); | | 207 | + haystack.release(); | | 208 | + } | | 209 | + | 199 | 210 | @ParameterizedTest | 200 | 211 | @ValueSource(ints = { 0, 1, 2, 3 }) | 201 | 212 | public void testIndexOfMatchesNaiveSearch(int needleReaderIndex) { | |
Collapse file Copy file name to clipboardExpand all lines: buffer/src/test/java/io/netty/buffer/UnpooledTest.java +31Lines changed: 31 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 | import java.io.InputStream; | 25 | 25 | import java.nio.ByteBuffer; | 26 | 26 | import java.nio.ByteOrder; | | 27 | +import java.nio.CharBuffer; | 27 | 28 | import java.nio.channels.ScatteringByteChannel; | 28 | 29 | import java.nio.charset.Charset; | 29 | 30 | import java.util.ArrayList; | @@ -358,6 +359,36 @@ private static void testCopiedBufferCharSequence(CharSequence sequence, Charset | 358 | 359 | } | 359 | 360 | } | 360 | 361 |
| | 362 | + @Test | | 363 | + public void testCopiedBufferCharBufferRegion() { | | 364 | + // CharBuffer.wrap(CharSequence) and read-only buffers are not backed by an accessible array. | | 365 | + testCopiedBufferCharBufferRegion(CharBuffer.wrap("hello world")); | | 366 | + testCopiedBufferCharBufferRegion(CharBuffer.wrap("hello world".toCharArray()).asReadOnlyBuffer()); | | 367 | + // Array backed. | | 368 | + testCopiedBufferCharBufferRegion(CharBuffer.wrap("hello world".toCharArray())); | | 369 | + } | | 370 | + | | 371 | + private static void testCopiedBufferCharBufferRegion(CharBuffer buffer) { | | 372 | + assertCopiedBufferRegion("llo w", buffer, 2, 5); | | 373 | + assertCopiedBufferRegion("world", buffer, 6, 5); | | 374 | + | | 375 | + // The offset is relative to the position of the buffer. | | 376 | + buffer.position(1); | | 377 | + assertCopiedBufferRegion("lo wo", buffer, 2, 5); | | 378 | + assertCopiedBufferRegion("world", buffer, 5, 5); | | 379 | + assertEquals(1, buffer.position()); | | 380 | + assertEquals(11, buffer.limit()); | | 381 | + } | | 382 | + | | 383 | + private static void assertCopiedBufferRegion(String expected, CharBuffer buffer, int offset, int length) { | | 384 | + ByteBuf copied = copiedBuffer(buffer, offset, length, CharsetUtil.US_ASCII); | | 385 | + try { | | 386 | + assertEquals(expected, copied.toString(CharsetUtil.US_ASCII)); | | 387 | + } finally { | | 388 | + copied.release(); | | 389 | + } | | 390 | + } | | 391 | + | 361 | 392 | @Test | 362 | 393 | public void testCopiedBuffer() { | 363 | 394 | ByteBuf copied = copiedBuffer(ByteBuffer.allocateDirect(16)); | |
Collapse file Copy file name to clipboardExpand all lines: codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicCodecDispatcher.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -120,7 +120,8 @@ public final void channelRead(ChannelHandlerContext ctx, Object msg) throws Exce | 120 | 120 | ByteBuf connectionId = getDestinationConnectionId(packet.content(), localConnectionIdLength); | 121 | 121 | if (connectionId != null) { | 122 | 122 | int idx = decodeIndex(connectionId); | 123 | | - if (contextList.size() > idx) { | | 123 | + // decodeIndex(...) returns -1 if decoding was not successful. | | 124 | + if (idx >= 0 && contextList.size() > idx) { | 124 | 125 | ChannelHandlerContextDispatcher selectedCtx = contextList.get(idx); | 125 | 126 | if (selectedCtx != null) { | 126 | 127 | selectedCtx.fireChannelRead(msg); | |
Collapse file Copy file name to clipboardExpand all lines: codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicHeaderParser.java +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -160,11 +160,13 @@ private static ByteBuf sliceToken(QuicPacketType type, ByteBuf packet, int offse | 160 | 160 | // See | 161 | 161 | checkReadable(offset, readable, Byte.BYTES); | 162 | 162 | int numBytes = numBytesForVariableLengthInteger(packet.getByte(offset)); | 163 | | - int len = (int) getVariableLengthInteger(packet, offset, numBytes); | | 163 | + // The token length is a variable length integer that can be up to 62 bits, so we must not narrow it | | 164 | + // to an int before we validated it against the readable bytes. | | 165 | + long len = getVariableLengthInteger(packet, offset, numBytes); | 164 | 166 | offset += numBytes; | 165 | 167 |
| 166 | 168 | checkReadable(offset, readable, len); | 167 | | - return packet.slice(offset, len); | | 169 | + return packet.slice(offset, (int) len); | 168 | 170 | case RETRY: | 169 | 171 | // Exclude the integrity tag from the token. | 170 | 172 | // See https://www.rfc-editor.org/rfc/rfc9000.html#section-17.2.5 | @@ -185,7 +187,7 @@ static ByteBuf sliceCid(ByteBuf buffer, int offset, int len) throws QuicExceptio | 185 | 187 | return buffer.slice(offset, len); | 186 | 188 | } | 187 | 189 |
| 188 | | - private static void checkReadable(int offset, int readable, int needed) throws QuicException { | | 190 | + private static void checkReadable(int offset, int readable, long needed) throws QuicException { | 189 | 191 | int r = readable - offset; | 190 | 192 | if (r < needed) { | 191 | 193 | throw newProtocolViolationException("Not enough bytes to read, " + r + " < " + needed); | |
Collapse file Copy file name to clipboardExpand all lines: codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheSendInfo.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -153,7 +153,7 @@ static long getAtNanos(ByteBuffer memory) { | 153 | 153 | long sec = Quiche.getPrimitiveValue(memory, Quiche.QUICHE_SEND_INFO_OFFSETOF_AT + | 154 | 154 | Quiche.TIMESPEC_OFFSETOF_TV_SEC, Quiche.SIZEOF_TIME_T); | 155 | 155 | long nsec = Quiche.getPrimitiveValue(memory, Quiche.QUICHE_SEND_INFO_OFFSETOF_AT + | 156 | | - Quiche.TIMESPEC_OFFSETOF_TV_SEC, Quiche.SIZEOF_LONG); | | 156 | + Quiche.TIMESPEC_OFFSETOF_TV_NSEC, Quiche.SIZEOF_LONG); | 157 | 157 | return TimeUnit.SECONDS.toNanos(sec) + nsec; | 158 | 158 | } | 159 | 159 |
| |
|