carterkozak commented on a change in pull request #243:
URL: 
https://github.com/apache/httpcomponents-client/pull/243#discussion_r465134285



##########
File path: 
httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/HttpClientConnectionFactoryManagedAdapter.java
##########
@@ -0,0 +1,215 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.client5.http.impl.io;
+
+import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.EndpointDetails;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.io.HttpConnectionFactory;
+import org.apache.hc.core5.io.CloseMode;
+import org.apache.hc.core5.util.Timeout;
+
+import javax.net.ssl.SSLSession;
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/** Adapter to use convert basic http client connection factories into managed 
http client connection factories. */
+public final class HttpClientConnectionFactoryManagedAdapter implements 
HttpConnectionFactory<ManagedHttpClientConnection> {
+
+    private final HttpConnectionFactory<HttpClientConnection> delegate;
+
+    public HttpClientConnectionFactoryManagedAdapter(final 
HttpConnectionFactory<HttpClientConnection> delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public ManagedHttpClientConnection createConnection(final Socket socket) 
throws IOException {
+        return new 
ManagedHttpClientConnectionAdapter(delegate.createConnection(socket));
+    }
+
+    @Override
+    public String toString() {
+        return "HttpClientConnectionFactoryManagedAdapter{" + delegate + '}';
+    }
+
+    private static final class ManagedHttpClientConnectionAdapter implements 
ManagedHttpClientConnection {
+
+        private final HttpClientConnection delegate;
+        private final AtomicBoolean closed = new AtomicBoolean();

Review comment:
       I'm not sure close tracking is necessary here, but I borrowed it from 
the DefaultManagedHttpClientConnection implementation.




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to