aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-03-01 10:08:00 +0300
committerGravatar Vitaly Takmazov2019-03-01 10:08:00 +0300
commite1e416608c2ed864cb7d93fc582dd267aa5a0b5e (patch)
tree384d86aed9e3e784329fa905b551f165fc00a33f
parentb53425e6b036f6760a5d0a98537f99b8d9509d34 (diff)
ImageUtils catch IOException from apache-imaging
-rw-r--r--src/main/java/com/juick/server/util/ImageUtils.java2
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java9
-rw-r--r--src/test/resources/2936611-57.jpgbin0 -> 101818 bytes
3 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/com/juick/server/util/ImageUtils.java b/src/main/java/com/juick/server/util/ImageUtils.java
index d16faf8f..2f5d3292 100644
--- a/src/main/java/com/juick/server/util/ImageUtils.java
+++ b/src/main/java/com/juick/server/util/ImageUtils.java
@@ -108,7 +108,7 @@ public class ImageUtils {
}
}
}
- } catch (ImageReadException e) {
+ } catch (ImageReadException | IOException e) {
// failed to read metadata.
// nothing to do here, return image as is.
}
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index c8f07d06..a0d10988 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -215,6 +215,8 @@ public class ServerTests {
private Resource hubzillaFollow;
@Value("classpath:announce.json")
private Resource noteWithDocument;
+ @Value("classpath:2936611-57.jpg")
+ private Resource jpegNoJfifTiff;
@Inject
private KeystoreManager testKeystoreManager;
@@ -1177,6 +1179,13 @@ public class ServerTests {
assertThat(postJpgiPhone.getNewMessage().get().getAttachment().getHeight(), is(1280));
assertThat(postJpgiPhone.getNewMessage().get().getAttachment().getMedium().getHeight(), is(1024));
assertThat(postJpgiPhone.getNewMessage().get().getAttachment().getSmall().getHeight(), is(512));
+ CommandResult postNojfifTiff = commandsManager.processCommand(ugnich, "YO2", jpegNoJfifTiff.getURI());
+ assertThat(postNojfifTiff.getNewMessage().isPresent(), is(true));
+ int mid2 = postNojfifTiff.getNewMessage().get().getMid();
+ File originalFile2 = Paths.get(imgDir, "p", String.format("%d.jpg", mid2)).toFile();
+ assertThat(originalFile2.exists(), is(true));
+ File mediumFile2 = Paths.get(imgDir, "photos-1024", String.format("%d.jpg", mid2)).toFile();
+ assertThat(mediumFile2.exists(), is(true));
}
@Test
public void changeExtensionWhenReceiveFileWithWrongContentType() throws Exception {
diff --git a/src/test/resources/2936611-57.jpg b/src/test/resources/2936611-57.jpg
new file mode 100644
index 00000000..af4f9c91
--- /dev/null
+++ b/src/test/resources/2936611-57.jpg
Binary files differ