You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2016/12/03 16:56:38 UTC
[44/50] tomee git commit: TOMEE-1623 backport to Java 6 and ensure
the inputstream is totally empty so it isn't incorrectly closed by the client
as opposed to being kept alive
TOMEE-1623 backport to Java 6 and ensure the inputstream is totally empty so it isn't incorrectly closed by the client as opposed to being kept alive
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/41d223ef
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/41d223ef
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/41d223ef
Branch: refs/heads/tomee-1.7.x
Commit: 41d223eff25875c96793d58ddded58e099cff03c
Parents: 6f4a535
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Sat Aug 27 22:47:28 2016 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Sat Aug 27 22:47:28 2016 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/openejb/client/Client.java | 11 +++++++++++
.../org/apache/openejb/client/HttpConnectionFactory.java | 11 +++--------
2 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/41d223ef/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java b/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
index 2834f2e..2e9a1d0 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
@@ -405,6 +405,17 @@ public class Client {
}
if (null != in) {
+
+ // consume anything left in the buffer
+ try {
+ int read = 0;
+ while (read > -1) {
+ read = in.read();
+ }
+ } catch (Throwable e) {
+ // ignore
+ }
+
try {
in.close();
} catch (final Throwable e) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/41d223ef/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java b/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
index a576f13..35845e9 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
@@ -18,6 +18,7 @@
package org.apache.openejb.client;
import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSocketFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -36,7 +37,7 @@ import java.util.concurrent.ConcurrentMap;
*/
public class HttpConnectionFactory implements ConnectionFactory {
// this map only ensures JVM keep alive socket caching works properly
- private final ConcurrentMap<URI, SSLSocketFactory> socketFactoryMap = new ConcurrentHashMap<>();
+ private final ConcurrentMap<URI, SSLSocketFactory> socketFactoryMap = new ConcurrentHashMap<URI, SSLSocketFactory>();
@Override
public Connection getConnection(final URI uri) throws IOException {
@@ -44,8 +45,6 @@ public class HttpConnectionFactory implements ConnectionFactory {
}
public static class HttpConnection implements Connection {
- private final ConcurrentMap<URI, SSLSocketFactory> socketFactoryMap;
-
private HttpURLConnection httpURLConnection;
private InputStream inputStream;
private OutputStream outputStream;
@@ -53,7 +52,6 @@ public class HttpConnectionFactory implements ConnectionFactory {
public HttpConnection(final URI uri, final ConcurrentMap<URI, SSLSocketFactory> socketFactoryMap) throws IOException {
this.uri = uri;
- this.socketFactoryMap = socketFactoryMap;
final URL url = uri.toURL();
final Map<String, String> params;
@@ -84,10 +82,7 @@ public class HttpConnectionFactory implements ConnectionFactory {
SSLSocketFactory sslSocketFactory = socketFactoryMap.get(uri);
if (sslSocketFactory == null) {
sslSocketFactory = new SSLContextBuilder(params).build().getSocketFactory();
- final SSLSocketFactory existing = socketFactoryMap.putIfAbsent(uri, sslSocketFactory);
- if (existing != null) {
- sslSocketFactory = existing;
- }
+ socketFactoryMap.put(uri, sslSocketFactory);
}
((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(sslSocketFactory);