Author: rwesten
Date: Wed Sep 28 18:46:38 2011
New Revision: 1177016
URL: http://svn.apache.org/viewvc?rev=1177016&view=rev
Log:
fixed STANBOL-326 and also fixed an issue that prevented the
HttpURLConnection.getErrorStream() not being closed
Modified:
incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java
Modified:
incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java?rev=1177016&r1=1177015&r2=1177016&view=diff
==============================================================================
---
incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java
(original)
+++
incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java
Wed Sep 28 18:46:38 2011
@@ -55,16 +55,18 @@ public final class SparqlEndpointUtils {
if(con instanceof HttpURLConnection){
//try to create a better Error Message
InputStream reason = ((HttpURLConnection)con).getErrorStream();
- String errorMessage = null;
- try {
- errorMessage = IOUtils.toString(reason);
- } catch (IOException e1) {
- //ignore ...
+ if(reason != null){
+ String errorMessage = null;
+ try {
+ errorMessage = IOUtils.toString(reason);
+ } catch (IOException e1) {
+ //ignore ...
+ }
+ IOUtils.closeQuietly(reason);
+ if(errorMessage != null && !errorMessage.isEmpty()){
+ throw new
IOException(((HttpURLConnection)con).getRequestMethod()+" with Content:
\n"+errorMessage,e);
+ }
}
- if(errorMessage != null && !errorMessage.isEmpty()){
- throw new
IOException(((HttpURLConnection)con).getRequestMethod()+" with Content:
\n"+errorMessage,e);
- }
- IOUtils.closeQuietly(reason);
}
//if still here re-throw the original exception
throw e;