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:
parent
3603905a54
commit
c45ad66f5f
|
@ -6,7 +6,11 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</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">
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
|
@ -26,7 +30,7 @@
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="owner.project.facets" value="java"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
|
12
pom.xml
12
pom.xml
|
@ -16,6 +16,12 @@
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- <dependency> -->
|
||||||
|
<!-- <groupId>org.apache.tomcat</groupId> -->
|
||||||
|
<!-- <artifactId>catalina</artifactId> -->
|
||||||
|
<!-- <version>6.0.16</version> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -102,7 +108,7 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/java</directory>
|
<directory>src/main/java</directory>
|
||||||
|
@ -110,7 +116,7 @@
|
||||||
<include>**/*.*</include>
|
<include>**/*.*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<includes>
|
<includes>
|
||||||
|
@ -120,7 +126,7 @@
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<finalName>${artifactId}</finalName>
|
<finalName>${artifactId}</finalName>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.datatransfer.resolver.http;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.net.SocketException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLStreamHandler;
|
import java.net.URLStreamHandler;
|
||||||
|
@ -106,7 +107,6 @@ public class HttpResolver extends HttpServlet {
|
||||||
response.setContentType("unknown/unknown");
|
response.setContentType("unknown/unknown");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
URL url = new URL(null, uri, new URLStreamHandler() {
|
URL url = new URL(null, uri, new URLStreamHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,21 +125,45 @@ public class HttpResolver extends HttpServlet {
|
||||||
}
|
}
|
||||||
catch(Exception e){
|
catch(Exception e){
|
||||||
response.sendError(404);
|
response.sendError(404);
|
||||||
logger.error("Exception:", e);
|
logger.error("URLConnection Exception:", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
IOUtils.copy(in, out);
|
IOUtils.copy(in, out);
|
||||||
|
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
in.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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
logger.error("Exception:", e);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue