Skip to content

Instantly share code, notes, and snippets.

@peterdietz
Created November 21, 2014 17:25
Show Gist options
  • Select an option

  • Save peterdietz/79baf241a0833fb28118 to your computer and use it in GitHub Desktop.

Select an option

Save peterdietz/79baf241a0833fb28118 to your computer and use it in GitHub Desktop.
Media Filter Manager that doesn't crash on large files, skips instead
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