Minor HttpClient resource cleanups
This commit is contained in:
parent
64eb5929a7
commit
83534d49be
3 changed files with 10 additions and 4 deletions
|
@ -45,6 +45,7 @@ import com.hp.hpl.jena.util.iterator.SingletonIterator;
|
|||
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||
import org.apache.http.protocol.BasicHttpContext;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
public class SparqlGraph implements GraphWithPerform {
|
||||
|
@ -97,7 +98,7 @@ public class SparqlGraph implements GraphWithPerform {
|
|||
meth.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
meth.setEntity(new UrlEncodedFormEntity(Arrays.asList(
|
||||
new BasicNameValuePair("update", updateString))));
|
||||
HttpResponse response = httpClient.execute(meth);
|
||||
HttpResponse response = httpClient.execute(meth, new BasicHttpContext());
|
||||
try {
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
if (statusCode > 399) {
|
||||
|
|
|
@ -932,7 +932,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
|
|||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return new BasicHttpContext();
|
||||
}
|
||||
|
||||
protected UsernamePasswordCredentials getCredentials() {
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
|
|||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
/**
|
||||
* Do some quick checks to see whether the OpenSocial stuff is configured and
|
||||
|
@ -384,8 +385,12 @@ public class OpenSocialSmokeTests implements ServletContextListener {
|
|||
try {
|
||||
log.debug("Trying to connect to Shindig");
|
||||
HttpResponse response = httpClient.execute(method);
|
||||
statusCode = response.getStatusLine().getStatusCode();
|
||||
log.debug("HTTP status was " + statusCode);
|
||||
try {
|
||||
statusCode = response.getStatusLine().getStatusCode();
|
||||
log.debug("HTTP status was " + statusCode);
|
||||
} finally {
|
||||
EntityUtils.consume(response.getEntity());
|
||||
}
|
||||
} catch (SocketTimeoutException e) {
|
||||
// Catch the exception so we can retry this.
|
||||
// Save the status so we know why we failed.
|
||||
|
|
Loading…
Add table
Reference in a new issue