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
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
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java2
-rw-r--r--org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java17
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java2
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java28
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java2
5 files changed, 26 insertions, 25 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
index 26ad9bf81..0f1146333 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
@@ -684,7 +684,7 @@ public class BugzillaClient {
} finally {
attempt++;
if (method != null) {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
}
}
}
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();
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java
index eb18ad949..e50191a8a 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java
@@ -114,7 +114,7 @@ public abstract class AbstractTracClient implements ITracClient {
throw new TracLoginException();
}
} finally {
- post.releaseConnection();
+ WebUtil.releaseConnection(post, monitor);
}
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java
index 4e9758cec..925a607dd 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java
@@ -46,11 +46,11 @@ import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer;
+import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token;
import org.eclipse.mylyn.commons.net.HtmlTag;
import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.commons.net.UnsupportedRequestException;
import org.eclipse.mylyn.commons.net.WebUtil;
-import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token;
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.model.TracComponent;
import org.eclipse.mylyn.internal.trac.core.model.TracMilestone;
@@ -58,16 +58,16 @@ import org.eclipse.mylyn.internal.trac.core.model.TracPriority;
import org.eclipse.mylyn.internal.trac.core.model.TracRepositoryInfo;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter;
+import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter.CompareOperator;
import org.eclipse.mylyn.internal.trac.core.model.TracSeverity;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
+import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
import org.eclipse.mylyn.internal.trac.core.model.TracTicketResolution;
import org.eclipse.mylyn.internal.trac.core.model.TracTicketStatus;
import org.eclipse.mylyn.internal.trac.core.model.TracTicketType;
import org.eclipse.mylyn.internal.trac.core.model.TracVersion;
-import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter.CompareOperator;
-import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
-import org.eclipse.mylyn.internal.trac.core.util.TracUtil;
import org.eclipse.mylyn.internal.trac.core.util.TracHttpClientTransportFactory.TracHttpException;
+import org.eclipse.mylyn.internal.trac.core.util.TracUtil;
/**
* Represents a Trac repository that is accessed through the Trac's query script and web interface.
@@ -108,17 +108,17 @@ public class TracWebClient extends AbstractTracClient {
try {
code = WebUtil.execute(httpClient, hostConfiguration, method, monitor);
} catch (IOException e) {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
throw e;
} catch (RuntimeException e) {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
throw e;
}
if (code == HttpURLConnection.HTTP_OK) {
return method;
} else {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
if (code == HttpURLConnection.HTTP_UNAUTHORIZED || code == HttpURLConnection.HTTP_FORBIDDEN) {
// login or re-authenticate due to an expired session
authenticated = false;
@@ -158,7 +158,7 @@ public class TracWebClient extends AbstractTracClient {
continue;
}
} finally {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
}
// the expected return code is a redirect, anything else is suspicious
@@ -311,7 +311,7 @@ public class TracWebClient extends AbstractTracClient {
} catch (ParseException e) {
throw new TracException(e);
} finally {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
}
}
@@ -382,7 +382,7 @@ public class TracWebClient extends AbstractTracClient {
} catch (IOException e) {
throw new TracException(e);
} finally {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
}
}
@@ -416,7 +416,7 @@ public class TracWebClient extends AbstractTracClient {
try {
return new TracRepositoryInfo();
} finally {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
}
}
@@ -455,7 +455,7 @@ public class TracWebClient extends AbstractTracClient {
} catch (ParseException e) {
throw new TracException(e);
} finally {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
}
}
@@ -660,7 +660,7 @@ public class TracWebClient extends AbstractTracClient {
} catch (ParseException e) {
throw new TracException(e);
} finally {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
}
}
@@ -744,7 +744,7 @@ public class TracWebClient extends AbstractTracClient {
// release the connection
return method.getResponseBodyAsStream();
} catch (IOException e) {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
throw new TracException(e);
}
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java
index 8f1d25a7e..b8a959684 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java
@@ -419,7 +419,7 @@ public class TracXmlRpcClient extends AbstractTracClient implements ITracWikiCli
} catch (IOException e) {
// ignore
} finally {
- method.releaseConnection();
+ WebUtil.releaseConnection(method, monitor);
}
}

Back to the top