Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2011-07-26 22:08:48 +0000
committerRyan D. Brooks2011-07-26 22:08:48 +0000
commit9e7b0d8b2bbb58c44539ccfc7441fec12c397ae8 (patch)
tree8fb79b19423341ae2bfccba68d5c3f2333cfce64
parent3453bd458333e2bae61b711796aa33b8865eee6b (diff)
downloadorg.eclipse.osee-9e7b0d8b2bbb58c44539ccfc7441fec12c397ae8.tar.gz
org.eclipse.osee-9e7b0d8b2bbb58c44539ccfc7441fec12c397ae8.tar.xz
org.eclipse.osee-9e7b0d8b2bbb58c44539ccfc7441fec12c397ae8.zip
refinement: Improve HttpProcessor performance
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java75
1 files changed, 17 insertions, 58 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
index e1ba63740ec..c0209e87d6e 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
@@ -59,6 +59,8 @@ public class HttpProcessor {
private static final long CHECK_WINDOW = 5000;
private static final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+ private static final HttpClient client = new HttpClient(connectionManager);
+
private static IProxyService proxyService;
private static final Map<String, IProxyData[]> proxiedData = new ConcurrentHashMap<String, IProxyData[]>();
@@ -72,7 +74,6 @@ public class HttpProcessor {
}
private static HttpClient getHttpClient(URI uri) {
- HttpClient client = new HttpClient(connectionManager);
HostConfiguration config = client.getHostConfiguration();
configureProxyData(uri, config);
return client;
@@ -233,15 +234,8 @@ public class HttpProcessor {
} catch (Exception ex) {
OseeExceptions.wrapAndThrow(ex);
} finally {
- try {
- if (responseInputStream != null) {
- responseInputStream.close();
- }
- } catch (Exception ex) {
- // Do Nothing;
- } finally {
- method.releaseConnection();
- }
+ Lib.close(responseInputStream);
+ method.releaseConnection();
}
return response;
}
@@ -272,16 +266,9 @@ public class HttpProcessor {
} catch (Exception ex) {
OseeExceptions.wrapAndThrow(ex);
} finally {
- try {
- result.setCode(statusCode);
- if (httpInputStream != null) {
- httpInputStream.close();
- }
- } catch (Exception ex) {
- // Do Nothing;
- } finally {
- method.releaseConnection();
- }
+ Lib.close(httpInputStream);
+ result.setCode(statusCode);
+ method.releaseConnection();
}
return result;
}
@@ -312,16 +299,9 @@ public class HttpProcessor {
} catch (Exception ex) {
OseeExceptions.wrapAndThrow(ex);
} finally {
- try {
- result.setCode(statusCode);
- if (httpInputStream != null) {
- httpInputStream.close();
- }
- } catch (Exception ex) {
- // Do Nothing;
- } finally {
- method.releaseConnection();
- }
+ Lib.close(httpInputStream);
+ result.setCode(statusCode);
+ method.releaseConnection();
}
return result;
}
@@ -349,15 +329,8 @@ public class HttpProcessor {
response = Lib.inputStreamToString(responseInputStream);
}
} finally {
- try {
- if (responseInputStream != null) {
- responseInputStream.close();
- }
- } catch (Exception ex) {
- // Do Nothing;
- } finally {
- method.releaseConnection();
- }
+ Lib.close(responseInputStream);
+ method.releaseConnection();
}
return response;
}
@@ -397,16 +370,9 @@ public class HttpProcessor {
} catch (Exception ex) {
throw new Exception(String.format("Error acquiring resource: [%s] - status code: [%s]", url, statusCode), ex);
} finally {
- try {
- result.setCode(statusCode);
- if (inputStream != null) {
- inputStream.close();
- }
- } catch (Exception ex) {
- // Do Nothing;
- } finally {
- method.releaseConnection();
- }
+ Lib.close(inputStream);
+ result.setCode(statusCode);
+ method.releaseConnection();
}
return result;
}
@@ -427,15 +393,8 @@ public class HttpProcessor {
} catch (Exception ex) {
throw new Exception(String.format("Error deleting resource: [%s] - status code: [%s]", url, statusCode), ex);
} finally {
- try {
- if (responseInputStream != null) {
- responseInputStream.close();
- }
- } catch (Exception ex) {
- // Do Nothing;
- } finally {
- method.releaseConnection();
- }
+ Lib.close(responseInputStream);
+ method.releaseConnection();
}
return response;
}

Back to the top