gnodet-bot commented on code in PR #2206:
URL: https://github.com/apache/maven-resolver/pull/2206#discussion_r4251690511


##########
maven-resolver-transport-jetty/src/main/java/org/eclipse/aether/transport/jetty/JettyTransporter.java:
##########
@@ -410,6 +413,19 @@ protected void implPut(PutTask task) throws Exception {
                     throw new HttpTransporterException(statusCode);
                 });
             }
+            // On some platforms (macOS) with certain configurations (proxy 
auth, TLS/HTTP2),
+            // Jetty may complete a small PUT without firing onRequestContent 
callbacks, leaving
+            // the progress listener uninformed even though the upload 
succeeded.
+            // Fire the missing events now that we know the request completed 
successfully.
+            if (task.getDataLength() > 0 && !progressed.get()) {
+                if (started.compareAndSet(false, true)) {
+                    task.getListener().transportStarted(0, 
task.getDataLength());
+                }
+                try (InputStream is = task.newInputStream()) {
+                    byte[] data = is.readAllBytes();
+                    
task.getListener().transportProgressed(ByteBuffer.wrap(data));

Review Comment:
   💡 **Memory observation:** `readAllBytes()` loads the entire upload payload 
into a single byte array before passing it to `transportProgressed`. For the 
typical case Jetty already coalesced (small PUT, macOS/proxy/TLS path), this is 
fine. If Jetty ever extends this coalescing behaviour to larger payloads, 
however, the retroactive path would materialise the full body in memory rather 
than streaming it chunk by chunk as the normal path does.
   
   A size guard or a buffered-chunked fallback would make this more defensive:
   
   ```suggestion
                   try (InputStream is = task.newInputStream()) {
                       byte[] buf = new byte[1024 * 32];
                       int n;
                       while ((n = is.read(buf)) != -1) {
                           
task.getListener().transportProgressed(ByteBuffer.wrap(buf, 0, n));
                       }
   ```
   
   Not a blocker for this fix, but worth considering for robustness.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to