Skip to content

Commit

Permalink
Merge pull request #4508 from IQSS/4473-thumbnails-exception-handling
Browse files Browse the repository at this point in the history
Relaxed exception handling in the thumbnail generator (#4473)
  • Loading branch information
kcondon authored Mar 16, 2018
2 parents fe558df + bb3caaf commit 285c20e
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static InputStreamIO getImageThumbnailAsInputStream(StorageIO<DataFile> s
inputStreamIO.setFileName(fileName);
}
return inputStreamIO;
} catch (IOException ioex) {
} catch (Exception ioex) {
if (cachedThumbnailInputStream != null) {
try {
cachedThumbnailInputStream.close();
Expand Down Expand Up @@ -216,7 +216,7 @@ private static boolean generatePDFThumbnail(StorageIO<DataFile> storageIO, int s
storageIO.open();
//inputStream = storageIO.getInputStream();
pdfFileChannel = storageIO.getReadChannel();
} catch (IOException ioex) {
} catch (Exception ioex) {
logger.warning("caught IOException trying to open an input stream for " + storageIO.getDataFile().getStorageIdentifier());
return false;
}
Expand Down Expand Up @@ -331,7 +331,7 @@ private static boolean generateImageThumbnailFromInputStream(StorageIO<DataFile>
try {
logger.fine("attempting to read the image file with ImageIO.read(InputStream), " + storageIO.getDataFile().getStorageIdentifier());
fullSizeImage = ImageIO.read(inputStream);
} catch (IOException ioex) {
} catch (Exception ioex) {
logger.warning("Caught exception attempting to read the image file with ImageIO.read(InputStream)");
return false;
}
Expand Down Expand Up @@ -361,7 +361,7 @@ private static boolean generateImageThumbnailFromInputStream(StorageIO<DataFile>
Channel outputChannel = storageIO.openAuxChannel(THUMBNAIL_SUFFIX + size, DataAccessOption.WRITE_ACCESS);
outputStream = Channels.newOutputStream((WritableByteChannel) outputChannel);
logger.fine("Opened an auxiliary channel/output stream " + THUMBNAIL_SUFFIX + size + " on " + storageIO.getDataFile().getStorageIdentifier());
} catch (IOException ioex) {
} catch (Exception ioex) {
logger.fine("Failed to open an auxiliary channel/output stream " + THUMBNAIL_SUFFIX + size + " on " + storageIO.getDataFile().getStorageIdentifier());
tempFileRequired = true;
}
Expand Down Expand Up @@ -393,7 +393,7 @@ private static boolean generateImageThumbnailFromInputStream(StorageIO<DataFile>
storageIO.savePathAsAux(Paths.get(tempFile.getAbsolutePath()), THUMBNAIL_SUFFIX + size);
}

} catch (IOException ioex) {
} catch (Exception ioex) {
logger.warning("Failed to rescale and/or save the image: " + ioex.getMessage());
return false;
}
Expand All @@ -406,7 +406,7 @@ private static boolean isThumbnailCached(StorageIO<DataFile> storageIO, int size
boolean cached;
try {
cached = storageIO.isAuxObjectCached(THUMBNAIL_SUFFIX + size);
} catch (IOException ioex) {
} catch (Exception ioex) {
logger.fine("caught IO exception while checking for a cached thumbnail (file " + storageIO.getDataFile().getStorageIdentifier() + ")");
return false;
}
Expand Down Expand Up @@ -441,7 +441,7 @@ public static String getImageThumbnailAsBase64(DataFile file, int size) {

try {
storageIO = file.getStorageIO();
} catch (IOException ioEx) {
} catch (Exception ioEx) {
logger.fine("Caught an exception while trying to obtain a thumbnail as Base64 string - could not open StorageIO on the datafile.");
return null;
}
Expand All @@ -467,7 +467,7 @@ public static String getImageThumbnailAsBase64(DataFile file, int size) {
Channel cachedThumbnailChannel = null;
try {
cachedThumbnailChannel = storageIO.openAuxChannel(THUMBNAIL_SUFFIX + size);
} catch (IOException ioEx) {
} catch (Exception ioEx) {
cachedThumbnailChannel = null;
}

Expand All @@ -488,7 +488,7 @@ public static String getImageThumbnailAsBase64(DataFile file, int size) {
// try to open again:
try {
cachedThumbnailChannel = storageIO.openAuxChannel(THUMBNAIL_SUFFIX + size);
} catch (IOException ioEx) {
} catch (Exception ioEx) {
cachedThumbnailChannel = null;
}
}
Expand Down Expand Up @@ -670,7 +670,7 @@ public static String rescaleImage(BufferedImage fullSizeImage, int width, int he

try {
rescaleImage(fullSizeImage, width, height, size, outputFileStream);
} catch (IOException ioex) {
} catch (Exception ioex) {
logger.warning("caught IO exceptiopn trying to create rescaled image " + outputLocation);
return null;
}
Expand Down

0 comments on commit 285c20e

Please sign in to comment.