mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
57866: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 57858: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.1) 57816: Merged DEV to V4.1-BUG-FIX (4.1.8) 57643: MNT-8989: MP4 and mov accessed over WebDav on safari or Chrome cause exceptions in log Added ClientAbortException check. Added unit tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61899 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -283,7 +283,7 @@ public class GetMethod extends WebDAVMethod
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
t = t.getCause();
|
t = t.getCause();
|
||||||
if (t instanceof SocketException)
|
if (t instanceof SocketException || t.getClass().getSimpleName().equals("ClientAbortException"))
|
||||||
{
|
{
|
||||||
logAsError = false;
|
logAsError = false;
|
||||||
}
|
}
|
||||||
|
@@ -186,4 +186,63 @@ public class GetMethodTest
|
|||||||
assertNull(e.getCause()); // Avoids logging stacking trace
|
assertNull(e.getCause()); // Avoids logging stacking trace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readByteRangeContentDoesNotLogClientAbortException() throws IOException, WebDAVServerException
|
||||||
|
{
|
||||||
|
// getContentService() during range request
|
||||||
|
when(davHelper.getServiceRegistry()).thenReturn(serviceRegistry);
|
||||||
|
when(serviceRegistry.getContentService()).thenReturn(contentService);
|
||||||
|
|
||||||
|
req.addHeader("Range", "bytes=500-1500");
|
||||||
|
getMethod.parseRequestHeaders();
|
||||||
|
IOException caEx = new ClientAbortException();
|
||||||
|
IOException ioEx = new IOException("Wrapping the socket exception.", caEx);
|
||||||
|
|
||||||
|
// Somewhere along the line a client disconnect will happen (IOException)
|
||||||
|
when(resp.getOutputStream()).thenThrow(ioEx);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
getMethod.readContent(fileInfo, reader);
|
||||||
|
fail("Exception should have been thrown.");
|
||||||
|
}
|
||||||
|
catch(WebDAVServerException e)
|
||||||
|
{
|
||||||
|
verify(logger, never()).error(anyString(), same(ioEx));
|
||||||
|
verify(logger).debug(anyString(), same(ioEx));
|
||||||
|
assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getHttpStatusCode());
|
||||||
|
assertNull(e.getCause()); // Avoids logging stacking trace
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readContentDoesNotLogClientAbortException() throws IOException, WebDAVServerException
|
||||||
|
{
|
||||||
|
IOException caEx = new ClientAbortException();
|
||||||
|
ContentIOException contentEx = new ContentIOException("Wrapping the socket exception.", caEx);
|
||||||
|
|
||||||
|
// Reader.getContent() will throw a ContentIOException when a client aborts.
|
||||||
|
doThrow(contentEx).when(reader).getContent(any(OutputStream.class));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
getMethod.readContent(fileInfo, reader);
|
||||||
|
fail("Exception should have been thrown.");
|
||||||
|
}
|
||||||
|
catch(WebDAVServerException e)
|
||||||
|
{
|
||||||
|
verify(logger, never()).error(anyString(), same(contentEx));
|
||||||
|
// Error will only be seen when debugging.
|
||||||
|
verify(logger).debug(anyString(), same(contentEx));
|
||||||
|
assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getHttpStatusCode());
|
||||||
|
assertNull(e.getCause()); // Avoids logging stacking trace
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fake ClientAbortException class - to emulate Tomcat's and JBOSS's ClientAbortException.
|
||||||
|
private static class ClientAbortException extends IOException
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user