Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-04-23 23:36:28 +0000
committerspingel2010-04-23 23:36:28 +0000
commit96015c1bd2d29e6d8cb8781c95649bd11a9200a5 (patch)
treee8d95a2ed4755c3563f588ebd071523405e1472b /org.eclipse.mylyn.oslc.core
parent1f601653e376c7c43bd059aa6ed7135cb91f5c96 (diff)
downloadorg.eclipse.mylyn.tasks-96015c1bd2d29e6d8cb8781c95649bd11a9200a5.tar.gz
org.eclipse.mylyn.tasks-96015c1bd2d29e6d8cb8781c95649bd11a9200a5.tar.xz
org.eclipse.mylyn.tasks-96015c1bd2d29e6d8cb8781c95649bd11a9200a5.zip
RESOLVED - bug 298156: [patch][api] provide method for canceling HTTP requests without blocking
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298156
Diffstat (limited to 'org.eclipse.mylyn.oslc.core')
-rw-r--r--org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java b/org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java
index a85005218..b70521d98 100644
--- a/org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java
+++ b/org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java
@@ -33,6 +33,7 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -558,23 +559,23 @@ public abstract class AbstractOslcClient {
protected <T> T executeMethod(HttpMethodBase method, RequestHandler<T> handler, IProgressMonitor monitor)
throws CoreException {
+ Assert.isNotNull(method);
monitor = Policy.monitorFor(monitor);
try {
monitor.beginTask(handler.getRequestName(), IProgressMonitor.UNKNOWN);
HostConfiguration hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
- int code = WebUtil.execute(httpClient, hostConfiguration, method, monitor);
-
- handler.handleReturnCode(code, method);
-
- return handler.run(method, monitor);
+ try {
+ int code = WebUtil.execute(httpClient, hostConfiguration, method, monitor);
+ handler.handleReturnCode(code, method);
+ return handler.run(method, monitor);
+ } finally {
+ WebUtil.releaseConnection(method, monitor);
+ }
} catch (IOException e) {
throw new CoreException(new Status(IStatus.WARNING, IOslcCoreConstants.ID_PLUGIN,
"An unexpected network error has occurred: " + e.getMessage(), e)); //$NON-NLS-1$
} finally {
- if (method != null) {
- method.releaseConnection();
- }
monitor.done();
}

Back to the top