cstamas commented on code in PR #1748:
URL: https://github.com/apache/maven-resolver/pull/1748#discussion_r2687599399


##########
maven-resolver-transport-jetty/src/main/java/org/eclipse/aether/transport/jetty/PutTaskRequestContent.java:
##########
@@ -18,118 +18,260 @@
  */
 package org.eclipse.aether.transport.jetty;
 
-import java.io.EOFException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.nio.channels.ByteChannel;
 import java.nio.channels.Channels;
+import java.nio.channels.ClosedChannelException;
 import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SeekableByteChannel;
 import java.nio.file.Files;
 import java.nio.file.StandardOpenOption;
+import java.util.Objects;
 
 import org.eclipse.aether.spi.connector.transport.PutTask;
-import org.eclipse.jetty.client.util.AbstractRequestContent;
+import org.eclipse.jetty.client.ByteBufferRequestContent;
+import org.eclipse.jetty.client.Request;
 import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.Content;
+import org.eclipse.jetty.io.RetainableByteBuffer;
+import org.eclipse.jetty.io.internal.ByteChannelContentSource;
 import org.eclipse.jetty.util.BufferUtil;
-import org.eclipse.jetty.util.Callback;
+import org.eclipse.jetty.util.ExceptionUtil;
 import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.util.TypeUtil;
+import org.eclipse.jetty.util.thread.AutoLock;
+import org.eclipse.jetty.util.thread.SerializedInvoker;
 
-class PutTaskRequestContent extends AbstractRequestContent {
-    private final PutTask putTask;
-    private final int bufferSize;
-    private ByteBufferPool bufferPool;
-    private boolean useDirectByteBuffers = true;
+/**
+ * Heavily inspired by Jetty's 
org.eclipse.jetty.io.internal.ByteChannelContentSource but adjusted to deal with
+ * ReadableByteChannels.
+ * Also Jetty's ByteChannelContentSource is an internal package so should not 
be used directly.
+ */
+public class PutTaskRequestContent extends ByteBufferRequestContent implements 
Request.Content {
 
-    PutTaskRequestContent(PutTask putTask) {
-        this(putTask, 4096);
+    public static Request.Content from(PutTask putTask) throws IOException {
+        ReadableByteChannel channel;
+        if (putTask.getDataPath() != null) {
+            channel = Files.newByteChannel(putTask.getDataPath(), 
StandardOpenOption.READ);
+        } else {
+            // TODO: support rewind for retries when using InputStream

Review Comment:
   
https://github.com/apache/maven-resolver/blob/1f01b66d782c592d3e073de3e734f797a74a988b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/PutTask.java#L58-L63
   
   PutTask carries either a file (`File` in Resolver 1 or `Path` in Resolver 2) 
or handful of bytes (as `byte[]`). Also is a `final` class, so maybe we just 
need to expose this?



-- 
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