Skip to content
Snippets Groups Projects
Commit 440851b2 authored by srosse's avatar srosse
Browse files

OO-4371: downgrade exceptions logged if browser abort request/download

parent 2ef2f3be
No related branches found
No related tags found
No related merge requests found
...@@ -197,6 +197,13 @@ public class CmdDownloadZip implements FolderCommand { ...@@ -197,6 +197,13 @@ public class CmdDownloadZip implements FolderCommand {
ZipUtil.addToZip(item, "", zout); ZipUtil.addToZip(item, "", zout);
} }
zout.flush(); zout.flush();
} catch (IOException e) {
String className = e.getClass().getSimpleName();
if("ClientAbortException".equals(className)) {
log.debug("client browser probably abort when downloading zipped files", e);
} else {
log.error("client browser probably abort when downloading zipped files", e);
}
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
} }
......
...@@ -97,19 +97,23 @@ public class MapperDispatcher implements Dispatcher { ...@@ -97,19 +97,23 @@ public class MapperDispatcher implements Dispatcher {
//an anonymous mapper? //an anonymous mapper?
m = mapperService.getMapperById(null, smappath); m = mapperService.getMapperById(null, smappath);
if(m == null) { if(m == null) {
log.warn("Call to mapped resource, but mapper does not exist for path::" + smappath); log.warn("Call to mapped resource, but mapper does not exist for path::{}", smappath);
hres.setStatus(HttpServletResponse.SC_NOT_FOUND); hres.setStatus(HttpServletResponse.SC_NOT_FOUND);
return; return;
} }
} }
String mod = slashPos > 0 ? subInfo.substring(slashPos) : ""; String mod = slashPos > 0 ? subInfo.substring(slashPos) : "";
if (mod.indexOf("..") != -1) { if (mod.indexOf("..") != -1) {
log.warn("Illegal mapper path::" + mod + " contains '..'"); log.warn("Illegal mapper path::{} contains '..'", mod);
hres.setStatus(HttpServletResponse.SC_FORBIDDEN); hres.setStatus(HttpServletResponse.SC_FORBIDDEN);
return; return;
} }
// /bla/blu.html // /bla/blu.html
MediaResource mr = m.handle(mod, hreq); MediaResource mr = m.handle(mod, hreq);
ServletUtil.serveResource(hreq, hres, mr); if(mr != null) {
ServletUtil.serveResource(hreq, hres, mr);
} else {
hres.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
} }
} }
\ No newline at end of file
...@@ -40,14 +40,15 @@ import org.olat.core.logging.AssertException; ...@@ -40,14 +40,15 @@ import org.olat.core.logging.AssertException;
* @author Felix Jost * @author Felix Jost
*/ */
public class MediaResourceMapper implements Mapper { public class MediaResourceMapper implements Mapper {
MediaResource mediaResource;
private MediaResource mediaResource;
public MediaResourceMapper() { public MediaResourceMapper() {
// //
} }
@Override
public MediaResource handle(String relPath, HttpServletRequest request) { public MediaResource handle(String relPath, HttpServletRequest request) {
if (mediaResource == null) throw new AssertException("mr already served, relPath =" + relPath + ",");
MediaResource r = mediaResource; MediaResource r = mediaResource;
mediaResource = null; mediaResource = null;
return r; return r;
...@@ -60,5 +61,4 @@ public class MediaResourceMapper implements Mapper { ...@@ -60,5 +61,4 @@ public class MediaResourceMapper implements Mapper {
if (this.mediaResource != null) throw new AssertException("mediaresource not yet served!"); if (this.mediaResource != null) throw new AssertException("mediaresource not yet served!");
this.mediaResource = mediaResource; this.mediaResource = mediaResource;
} }
} }
\ No newline at end of file
...@@ -109,7 +109,7 @@ public class ZipUtil { ...@@ -109,7 +109,7 @@ public class ZipUtil {
xxunzip(in, targetDir.getAbsolutePath()); xxunzip(in, targetDir.getAbsolutePath());
return true; return true;
} catch (IOException e) { } catch (IOException e) {
log.error("I/O failure while unzipping "+zipFile.getAbsolutePath()+" to "+targetDir.getAbsolutePath()); handleIOException("I/O failure while unzipping " + zipFile.getAbsolutePath() + " to " + targetDir.getAbsolutePath(), e);
return false; return false;
} }
} }
...@@ -128,7 +128,7 @@ public class ZipUtil { ...@@ -128,7 +128,7 @@ public class ZipUtil {
xxunzip(in, outdir); xxunzip(in, outdir);
return true; return true;
} catch (IOException e) { } catch (IOException e) {
log.error("I/O failure while unzipping "+zipLeaf.getName()+" to "+outdir); handleIOException("I/O failure while unzipping " + zipLeaf.getName() + " to " + outdir, e);
return false; return false;
} }
} }
...@@ -150,7 +150,7 @@ public class ZipUtil { ...@@ -150,7 +150,7 @@ public class ZipUtil {
xxunzip (in, outdir); xxunzip (in, outdir);
return true; return true;
} catch (IOException e) { } catch (IOException e) {
log.error("I/O failure while unzipping "+zipFile.getName()+" to "+outdir); handleIOException("I/O failure while unzipping " + zipFile.getName() + " to " + outdir, e);
return false; return false;
} }
} }
...@@ -171,7 +171,7 @@ public class ZipUtil { ...@@ -171,7 +171,7 @@ public class ZipUtil {
try(InputStream in = zipLeaf.getInputStream()) { try(InputStream in = zipLeaf.getInputStream()) {
unzipped = unzip(in, targetDir, identity, versioning); unzipped = unzip(in, targetDir, identity, versioning);
} catch(Exception e) { } catch(Exception e) {
log.error("", e); handleIOException("", e);
} }
return unzipped; return unzipped;
} }
...@@ -268,7 +268,7 @@ public class ZipUtil { ...@@ -268,7 +268,7 @@ public class ZipUtil {
try(OutputStream out = newEntry.getOutputStream(false)) { try(OutputStream out = newEntry.getOutputStream(false)) {
return FileUtils.copy(oZip, out); return FileUtils.copy(oZip, out);
} catch(Exception e) { } catch(Exception e) {
log.error("", e); handleIOException("", e);
return false; return false;
} }
} }
...@@ -288,7 +288,7 @@ public class ZipUtil { ...@@ -288,7 +288,7 @@ public class ZipUtil {
try(InputStream in = zipLeaf.getInputStream()) { try(InputStream in = zipLeaf.getInputStream()) {
unzipped = unzipNonStrict(in, targetDir, identity, versioning); unzipped = unzipNonStrict(in, targetDir, identity, versioning);
} catch(IOException e) { } catch(IOException e) {
log.error("", e); handleIOException("", e);
} }
return unzipped; return unzipped;
} }
...@@ -299,7 +299,7 @@ public class ZipUtil { ...@@ -299,7 +299,7 @@ public class ZipUtil {
InputStream bin = new BufferedInputStream(in, FileUtils.BSIZE)) { InputStream bin = new BufferedInputStream(in, FileUtils.BSIZE)) {
unzipped = unzipNonStrict(bin, targetDir, identity, versioning); unzipped = unzipNonStrict(bin, targetDir, identity, versioning);
} catch(IOException e) { } catch(IOException e) {
log.error("", e); handleIOException("", e);
} }
return unzipped; return unzipped;
} }
...@@ -382,7 +382,7 @@ public class ZipUtil { ...@@ -382,7 +382,7 @@ public class ZipUtil {
try(InputStream in = new ShieldInputStream(oZip)) { try(InputStream in = new ShieldInputStream(oZip)) {
return VFSManager.copyContent(in, newEntry); return VFSManager.copyContent(in, newEntry);
} catch(Exception e) { } catch(Exception e) {
log.error("", e); handleIOException("", e);
return false; return false;
} }
} }
...@@ -391,7 +391,7 @@ public class ZipUtil { ...@@ -391,7 +391,7 @@ public class ZipUtil {
try(OutputStream sout = new ShieldOutputStream(out)) { try(OutputStream sout = new ShieldOutputStream(out)) {
return VFSManager.copyContent(leaf, sout); return VFSManager.copyContent(leaf, sout);
} catch(Exception e) { } catch(Exception e) {
log.error("", e); handleIOException("", e);
return false; return false;
} }
} }
...@@ -635,7 +635,7 @@ public class ZipUtil { ...@@ -635,7 +635,7 @@ public class ZipUtil {
zip(container, out); zip(container, out);
return true; return true;
} catch(IOException e) { } catch(IOException e) {
log.error("", e); handleIOException("", e);
return false; return false;
} }
} }
...@@ -656,7 +656,7 @@ public class ZipUtil { ...@@ -656,7 +656,7 @@ public class ZipUtil {
} }
return true; return true;
} catch(IOException e) { } catch(IOException e) {
log.error("", e); handleIOException("", e);
return false; return false;
} }
} }
...@@ -718,7 +718,7 @@ public class ZipUtil { ...@@ -718,7 +718,7 @@ public class ZipUtil {
if (vfsItem instanceof LocalImpl) { if (vfsItem instanceof LocalImpl) {
name = ((LocalImpl)vfsItem).getBasefile().getAbsolutePath(); name = ((LocalImpl)vfsItem).getBasefile().getAbsolutePath();
} }
log.error("I/O error while adding "+name+" to zip:"+ioe); handleIOException("I/O error while adding " + name + " to zip:", ioe);
return false; return false;
} }
return success; return success;
...@@ -771,7 +771,7 @@ public class ZipUtil { ...@@ -771,7 +771,7 @@ public class ZipUtil {
} }
}); });
} catch (IOException e) { } catch (IOException e) {
log.error("", e); handleIOException("", e);
} }
} }
...@@ -787,7 +787,7 @@ public class ZipUtil { ...@@ -787,7 +787,7 @@ public class ZipUtil {
FileUtils.copy(source, exportStream); FileUtils.copy(source, exportStream);
exportStream.closeEntry(); exportStream.closeEntry();
} catch(IOException e) { } catch(IOException e) {
log.error("", e); handleIOException("", e);
} }
} }
...@@ -797,7 +797,7 @@ public class ZipUtil { ...@@ -797,7 +797,7 @@ public class ZipUtil {
FileUtils.copy(source, exportStream); FileUtils.copy(source, exportStream);
exportStream.closeEntry(); exportStream.closeEntry();
} catch(IOException e) { } catch(IOException e) {
log.error("", e); handleIOException("", e);
} }
} }
...@@ -822,7 +822,7 @@ public class ZipUtil { ...@@ -822,7 +822,7 @@ public class ZipUtil {
try(InputStream in=Files.newInputStream(file)) { try(InputStream in=Files.newInputStream(file)) {
FileUtils.copy(in, exportStream); FileUtils.copy(in, exportStream);
} catch (Exception e) { } catch (Exception e) {
log.error("", e); handleIOException("", e);
} }
exportStream.closeEntry(); exportStream.closeEntry();
...@@ -831,7 +831,7 @@ public class ZipUtil { ...@@ -831,7 +831,7 @@ public class ZipUtil {
} }
}); });
} catch (IOException e) { } catch (IOException e) {
log.error("", e); handleIOException("", e);
} }
} }
...@@ -878,7 +878,20 @@ public class ZipUtil { ...@@ -878,7 +878,20 @@ public class ZipUtil {
FileUtils.cpio(new BufferedInputStream(zis), bos, "unzip:" + of.getName()); FileUtils.cpio(new BufferedInputStream(zis), bos, "unzip:" + of.getName());
bos.flush(); bos.flush();
} catch(IOException e) { } catch(IOException e) {
log.error("", e); handleIOException("", e);
}
}
private static final void handleIOException(String msg, Exception e) {
try {
String className = e.getClass().getSimpleName();
if("ClientAbortException".equals(className)) {
log.debug("client browser probably abort during operaation", e);
} else {
log.error(msg, e);
}
} catch (Exception e1) {
log.error("", e1);
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment