aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src/main/java/com/juick/server/util
diff options
context:
space:
mode:
Diffstat (limited to 'juick-common/src/main/java/com/juick/server/util')
-rw-r--r--juick-common/src/main/java/com/juick/server/util/ImageUtils.java11
1 files changed, 3 insertions, 8 deletions
diff --git a/juick-common/src/main/java/com/juick/server/util/ImageUtils.java b/juick-common/src/main/java/com/juick/server/util/ImageUtils.java
index cea4cc88..d6a455a4 100644
--- a/juick-common/src/main/java/com/juick/server/util/ImageUtils.java
+++ b/juick-common/src/main/java/com/juick/server/util/ImageUtils.java
@@ -156,19 +156,14 @@ public class ImageUtils {
Iterator<ImageReader> iter = ImageIO.getImageReadersBySuffix(suffix);
while(iter.hasNext()) {
ImageReader reader = iter.next();
- ImageInputStream stream = null;
- try {
- stream = new FileImageInputStream(imgFile);
+ try (ImageInputStream stream = ImageIO.createImageInputStream(imgFile)) {
reader.setInput(stream);
attachment.setWidth(reader.getWidth(reader.getMinIndex()));
attachment.setHeight(reader.getHeight(reader.getMinIndex()));
return attachment;
- } catch (IOException e) {
- logger.warn("Error reading: " + imgFile.getAbsolutePath(), e);
+ } catch (Exception e) {
+ logger.debug("Error reading {}, trying next reader", imgFile.getAbsolutePath());
} finally {
- if (stream != null) {
- stream.close();
- }
reader.dispose();
}
}