You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2014/07/16 18:20:07 UTC
svn commit: r1611067 -
/tomee/tomee/branches/tomee-1.7.x/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
Author: andygumbrecht
Date: Wed Jul 16 16:20:06 2014
New Revision: 1611067
URL: http://svn.apache.org/r1611067
Log:
Be more forgiving on connect.
Modified:
tomee/tomee/branches/tomee-1.7.x/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
Modified: tomee/tomee/branches/tomee-1.7.x/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java?rev=1611067&r1=1611066&r2=1611067&view=diff
==============================================================================
--- tomee/tomee/branches/tomee-1.7.x/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java (original)
+++ tomee/tomee/branches/tomee-1.7.x/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java Wed Jul 16 16:20:06 2014
@@ -53,39 +53,48 @@ public class HttpConnectionFactory imple
final Map<String, String> params;
try {
params = MulticastConnectionFactory.URIs.parseParamters(uri);
- } catch (URISyntaxException e) {
+ } catch (final URISyntaxException e) {
throw new IllegalArgumentException("Invalid uri " + uri.toString(), e);
}
httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setDoOutput(true);
+ final int timeout;
if (params.containsKey("connectTimeout")) {
- httpURLConnection.setConnectTimeout(Integer.parseInt(params.get("connectTimeout")));
+ timeout = Integer.parseInt(params.get("connectTimeout"));
+ } else {
+ timeout = 10000;
}
+ httpURLConnection.setConnectTimeout(timeout);
+
if (params.containsKey("readTimeout")) {
httpURLConnection.setReadTimeout(Integer.parseInt(params.get("readTimeout")));
}
if (params.containsKey("sslKeyStore") || params.containsKey("sslTrustStore")) {
try {
- ( (HttpsURLConnection) httpURLConnection ).setSSLSocketFactory(new SSLContextBuilder(params).build().getSocketFactory());
- } catch (NoSuchAlgorithmException e) {
+ ((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(new SSLContextBuilder(params).build().getSocketFactory());
+ } catch (final NoSuchAlgorithmException e) {
throw new ClientRuntimeException(e.getMessage(), e);
- } catch (KeyManagementException e) {
+ } catch (final KeyManagementException e) {
throw new ClientRuntimeException(e.getMessage(), e);
}
}
- httpURLConnection.connect();
+ try {
+ httpURLConnection.connect();
+ } catch (final IOException e) {
+ httpURLConnection.connect();
+ }
}
@Override
public void discard() {
try {
close();
- } catch (Exception e) {
+ } catch (final Exception e) {
//Ignore
}
}
@@ -101,14 +110,14 @@ public class HttpConnectionFactory imple
if (inputStream != null) {
try {
inputStream.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
exception = e;
}
}
if (outputStream != null) {
try {
outputStream.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
if (exception == null) {
exception = e;
}