updated to fix ClientAbortException

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@101610 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-11-13 14:19:08 +00:00
parent 3603905a54
commit c45ad66f5f
3 changed files with 44 additions and 10 deletions

View File

@ -6,7 +6,11 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
@ -26,7 +30,7 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

12
pom.xml
View File

@ -16,6 +16,12 @@
</properties>
<dependencies>
<!-- <dependency> -->
<!-- <groupId>org.apache.tomcat</groupId> -->
<!-- <artifactId>catalina</artifactId> -->
<!-- <version>6.0.16</version> -->
<!-- </dependency> -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -102,7 +108,7 @@
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
@ -110,7 +116,7 @@
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
@ -120,7 +126,7 @@
</resources>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -3,6 +3,7 @@ package org.gcube.datatransfer.resolver.http;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
@ -106,7 +107,6 @@ public class HttpResolver extends HttpServlet {
response.setContentType("unknown/unknown");
URL url = new URL(null, uri, new URLStreamHandler() {
@Override
@ -125,21 +125,45 @@ public class HttpResolver extends HttpServlet {
}
catch(Exception e){
response.sendError(404);
logger.error("Exception:", e);
logger.error("URLConnection Exception:", e);
return;
}
/*
IOUtils.copy(in, out);
out.flush();
out.close();
in.close();
*/
//CHANGED BY FRANCESCO M.
try {
IOUtils.copy(in, out);
} catch (SocketException e){
if (!e.getClass().getSimpleName().equals("ClientAbortException"))
throw e;
else
logger.warn("Skipping ClientAbortException: "+e.getMessage());
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
logger.error("Exception:", e);
response.sendError(404);
// response.sendError(404);
//CHANGED BY FRANCESCO M.
if(!response.isCommitted())
response.sendError(404);
else
logger.warn("Response already committed, skipped send Error 404");
return;
}