Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2010-03-31 12:48:28 -0400
committerfbecker2010-03-31 12:48:28 -0400
commitdee7da7c3f3f8fe43ab25d60f01a363f1ae8a5ba (patch)
tree562e7faa25f333d6a4e089b48f58ba15cf27c6cc
parentd7bbee70b22849967fae042f3c61619105c422ee (diff)
downloadorg.eclipse.mylyn.tasks-dee7da7c3f3f8fe43ab25d60f01a363f1ae8a5ba.tar.gz
org.eclipse.mylyn.tasks-dee7da7c3f3f8fe43ab25d60f01a363f1ae8a5ba.tar.xz
org.eclipse.mylyn.tasks-dee7da7c3f3f8fe43ab25d60f01a363f1ae8a5ba.zip
ASSIGNED - bug 299555: Bugzilla connector should not invoke getResponseBody()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=299555
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java32
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipGetMethod.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipPostMethod.java7
3 files changed, 37 insertions, 9 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 c44d6369f..3bc6b5de4 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
@@ -661,7 +661,13 @@ public class BugzillaClient {
try {
int status = WebUtil.execute(httpClient, hostConfiguration, method, monitor);
if (status == HttpStatus.SC_OK) {
- out.write(method.getResponseBody());
+// ignore the response
+ InputStream instream = method.getResponseBodyAsStream();
+ byte[] buffer = new byte[4096];
+ int len;
+ while ((len = instream.read(buffer)) > 0) {
+ out.write(buffer, 0, len);
+ }
} else {
parseHtmlError(method.getResponseBodyAsStream());
}
@@ -1896,7 +1902,11 @@ public class BugzillaClient {
try {
code = WebUtil.execute(httpClient, hostConfiguration, headMethod, monitor);
} catch (IOException e) {
- headMethod.getResponseBody();
+// ignore the response
+ InputStream instream = headMethod.getResponseBodyAsStream();
+ byte[] buffer = new byte[4096];
+ while (instream.read(buffer) > 0) {
+ }
headMethod.releaseConnection();
throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
RepositoryStatus.ERROR_IO, repositoryUrl.toString(), e));
@@ -1905,20 +1915,32 @@ public class BugzillaClient {
if (code == HttpURLConnection.HTTP_OK) {
return headMethod;
} else if (code == HttpURLConnection.HTTP_UNAUTHORIZED || code == HttpURLConnection.HTTP_FORBIDDEN) {
- headMethod.getResponseBody();
+// ignore the response
+ InputStream instream = headMethod.getResponseBodyAsStream();
+ byte[] buffer = new byte[4096];
+ while (instream.read(buffer) > 0) {
+ }
// login or reauthenticate due to an expired session
headMethod.releaseConnection();
loggedIn = false;
authenticate(monitor);
} else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
loggedIn = false;
- headMethod.getResponseBody();
+// ignore the response
+ InputStream instream = headMethod.getResponseBodyAsStream();
+ byte[] buffer = new byte[4096];
+ while (instream.read(buffer) > 0) {
+ }
headMethod.releaseConnection();
throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(),
"Proxy authentication required")); //$NON-NLS-1$
} else {
- headMethod.getResponseBody();
+// ignore the response
+ InputStream instream = headMethod.getResponseBodyAsStream();
+ byte[] buffer = new byte[4096];
+ while (instream.read(buffer) > 0) {
+ }
headMethod.releaseConnection();
throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
RepositoryStatus.ERROR_NETWORK, "Http error: " + HttpStatus.getStatusText(code))); //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipGetMethod.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipGetMethod.java
index bf6dfbcc8..2569586c7 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipGetMethod.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipGetMethod.java
@@ -12,6 +12,7 @@
package org.eclipse.mylyn.internal.bugzilla.core;
import java.io.IOException;
+import java.io.InputStream;
import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.HttpException;
@@ -29,7 +30,6 @@ import org.apache.commons.httpclient.methods.GetMethod;
* </ul>
*
* @see GzipPostMethod, GetMethod
- *
* @author Maarten Meijer
*/
public class GzipGetMethod extends GetMethod {
@@ -64,7 +64,10 @@ public class GzipGetMethod extends GetMethod {
*/
public void getResponseBodyNoop() throws IOException {
// result is ignored
- super.getResponseBody();
+ InputStream instream = getResponseBodyAsStream();
+ byte[] buffer = new byte[4096];
+ while (instream.read(buffer) > 0) {
+ }
}
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipPostMethod.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipPostMethod.java
index d85e002e1..f3faf3b8a 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipPostMethod.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/GzipPostMethod.java
@@ -12,6 +12,7 @@
package org.eclipse.mylyn.internal.bugzilla.core;
import java.io.IOException;
+import java.io.InputStream;
import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.HttpException;
@@ -29,7 +30,6 @@ import org.apache.commons.httpclient.methods.PostMethod;
* </ul>
*
* @see GzipGetMethod, PostMethod
- *
* @author Maarten Meijer
*/
public class GzipPostMethod extends PostMethod {
@@ -64,6 +64,9 @@ public class GzipPostMethod extends PostMethod {
*/
public void getResponseBodyNoop() throws IOException {
// result is ignored
- super.getResponseBody();
+ InputStream instream = getResponseBodyAsStream();
+ byte[] buffer = new byte[4096];
+ while (instream.read(buffer) > 0) {
+ }
}
}

Back to the top