You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2026/09/26 12:17:44 UTC

(maven-resolver) branch master updated: fix: propagate fatal errors from Jetty request content (#2161)

This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git


The following commit(s) were added to refs/heads/master by this push:
     new ea7524026 fix: propagate fatal errors from Jetty request content (#2161)
ea7524026 is described below

commit ea7524026be57e822ca0da42443854b62eef6dfe
Author: Efe <go...@gmail.com>
AuthorDate: Sat Sep 26 15:17:39 2026 +0300

    fix: propagate fatal errors from Jetty request content (#2161)
    
    ## Summary
    
    Stop converting fatal JVM errors raised while reading or rewinding Jetty request content into ordinary failed content chunks.
    
    ## Changes
    
    - Catch `Exception` rather than `Throwable` in `PutTaskRequestContent` for recoverable channel failures.
    - Add regression coverage proving that errors from both `read()` and `rewind()` propagate to the caller.
    
    ## Testing
    
    - `mvn -pl maven-resolver-transport-jetty -am -DskipITs -Drat.skip -Dspotless.skip=true verify` — passed.
    - Focused pre-fix regression test failed as expected, then passed after the fix: `PutTaskRequestContentTest` (2 tests).
    - Full relevant reactor tests: 103 Jetty tests passed (10 skipped), with all upstream reactor tests passing.
    - Checkstyle and `git diff --check` — passed.
    - Spotless could not complete on the installed Java 27 runtime because the bundled Palantir formatter raises `NoSuchFieldError`; this is an environment/tooling compatibility issue affecting existing files.
    
    ## Notes
    
    - No overlapping open PR was found for #1988 or `PutTaskRequestContent`.
    - The complete diff was reviewed by the submitter; AI assistance was used during implementation.
    
    Fixes #1988
    
    
    Signed-off-by: Efe Gökdemir <ef...@rexcode.co.uk>
---
 .../transport/jetty/PutTaskRequestContent.java     |  8 +-
 .../transport/jetty/PutTaskRequestContentTest.java | 97 ++++++++++++++++++++++
 2 files changed, 101 insertions(+), 4 deletions(-)

diff --git a/maven-resolver-transport-jetty/src/main/java/org/eclipse/aether/transport/jetty/PutTaskRequestContent.java b/maven-resolver-transport-jetty/src/main/java/org/eclipse/aether/transport/jetty/PutTaskRequestContent.java
index 3c5761e2a..026b728cd 100644
--- a/maven-resolver-transport-jetty/src/main/java/org/eclipse/aether/transport/jetty/PutTaskRequestContent.java
+++ b/maven-resolver-transport-jetty/src/main/java/org/eclipse/aether/transport/jetty/PutTaskRequestContent.java
@@ -243,8 +243,8 @@ public class PutTaskRequestContent extends ByteBufferRequestContent implements R
                     return last;
                 }
                 lockedSetTerminal(Content.Chunk.EOF);
-            } catch (Throwable t) {
-                lockedSetTerminal(Content.Chunk.from(t, true));
+            } catch (Exception e) {
+                lockedSetTerminal(Content.Chunk.from(e, true));
             }
         }
         return terminal;
@@ -295,8 +295,8 @@ public class PutTaskRequestContent extends ByteBufferRequestContent implements R
                 offsetRemaining = 0;
                 totalRead = 0;
                 return true;
-            } catch (Throwable t) {
-                lockedSetTerminal(Content.Chunk.from(t, true));
+            } catch (Exception e) {
+                lockedSetTerminal(Content.Chunk.from(e, true));
             }
 
             return true;
diff --git a/maven-resolver-transport-jetty/src/test/java/org/eclipse/aether/transport/jetty/PutTaskRequestContentTest.java b/maven-resolver-transport-jetty/src/test/java/org/eclipse/aether/transport/jetty/PutTaskRequestContentTest.java
new file mode 100644
index 000000000..c904d9ed4
--- /dev/null
+++ b/maven-resolver-transport-jetty/src/test/java/org/eclipse/aether/transport/jetty/PutTaskRequestContentTest.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether.transport.jetty;
+
+import java.nio.ByteBuffer;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SeekableByteChannel;
+
+import org.eclipse.jetty.io.ByteBufferPool;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class PutTaskRequestContentTest {
+    @Test
+    void readPropagatesErrorsFromChannel() {
+        ReadableByteChannel channel = new ReadableByteChannel() {
+            @Override
+            public int read(ByteBuffer destination) {
+                throw new AssertionError("fatal read failure");
+            }
+
+            @Override
+            public boolean isOpen() {
+                return true;
+            }
+
+            @Override
+            public void close() {}
+        };
+        PutTaskRequestContent content = new PutTaskRequestContent(ByteBufferPool.SIZED_NON_POOLING, () -> channel);
+
+        assertThrows(AssertionError.class, content::read);
+    }
+
+    @Test
+    void rewindPropagatesErrorsFromSeekableChannel() {
+        SeekableByteChannel channel = new SeekableByteChannel() {
+            @Override
+            public int read(ByteBuffer destination) {
+                return -1;
+            }
+
+            @Override
+            public int write(ByteBuffer source) {
+                return 0;
+            }
+
+            @Override
+            public long position() {
+                return 0;
+            }
+
+            @Override
+            public SeekableByteChannel position(long newPosition) {
+                throw new AssertionError("fatal rewind failure");
+            }
+
+            @Override
+            public long size() {
+                return 0;
+            }
+
+            @Override
+            public SeekableByteChannel truncate(long size) {
+                return this;
+            }
+
+            @Override
+            public boolean isOpen() {
+                return true;
+            }
+
+            @Override
+            public void close() {}
+        };
+        PutTaskRequestContent content = new PutTaskRequestContent(ByteBufferPool.SIZED_NON_POOLING, () -> channel);
+
+        assertThrows(AssertionError.class, content::rewind);
+    }
+}