Created
November 21, 2014 17:25
-
-
Save peterdietz/79baf241a0833fb28118 to your computer and use it in GitHub Desktop.
Media Filter Manager that doesn't crash on large files, skips instead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/MediaFilterManager.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/MediaFilterManager.java | |
| index 8b27b59..220e745 100644 | |
| --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/MediaFilterManager.java | |
| +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/MediaFilterManager.java | |
| @@ -734,16 +734,32 @@ public class MediaFilterManager | |
| return false; | |
| } | |
| - InputStream destStream = formatFilter.getDestinationStream(source.retrieve()); | |
| - if (destStream == null) | |
| + InputStream destStream; | |
| + try { | |
| + System.out.println("File: " + newName); | |
| + /*InputStream*/ destStream = formatFilter.getDestinationStream(source.retrieve()); | |
| + if (destStream == null) | |
| + { | |
| + if (!isQuiet) | |
| + { | |
| + System.out.println("SKIPPED: bitstream " + source.getID() | |
| + + " (item: " + item.getHandle() + ") because filtering was unsuccessful"); | |
| + } | |
| + | |
| + return false; | |
| + } | |
| + } | |
| + catch (OutOfMemoryError oome) | |
| { | |
| - if (!isQuiet) | |
| + /*** | |
| + log.error("Error parsing PDF document " + oome.getMessage(), oome); | |
| + if (!ConfigurationManager.getBooleanProperty("pdffilter.skiponmemoryexception", false)) | |
| { | |
| - System.out.println("SKIPPED: bitstream " + source.getID() | |
| - + " (item: " + item.getHandle() + ") because filtering was unsuccessful"); | |
| + throw oome; | |
| } | |
| - | |
| - return false; | |
| + ***/ | |
| + System.out.println("!!! OutOfMemoryError !!!"); | |
| + return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment