Permalink
Browse files

Fixed NullPointerException cases on snapshot images parsing.

  • Loading branch information...
luccioman committed Oct 18, 2017
1 parent 285f0d6 commit a17a418e78d6e77f5f29d306cfd566225d657af5
Showing with 9 additions and 1 deletion.
  1. +4 −0 htroot/api/snapshot.java
  2. +5 −1 source/net/yacy/cora/util/Html2Image.java
@@ -304,6 +304,10 @@ public static Object respond(final RequestHeader header, serverObjects post, fin
Image image;
try {
image = ImageParser.parse(imageFile.getAbsolutePath(), FileUtils.read(imageFile));
if(image == null) {
/* Should not happen. If so, ImageParser.parse() should already have logged about the error */
return null;
}
final Image scaled = image.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING);
final MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(scaled, 0);
@@ -199,7 +199,11 @@ public static boolean pdf2image(final File pdf, final File image, final int widt
try {
File newPngFile = new File(pngFile.getAbsolutePath() + ".png");
pngFile.renameTo(newPngFile);
Image img = ImageParser.parse(pngFile.getAbsolutePath(), FileUtils.read(newPngFile));
final Image img = ImageParser.parse(pngFile.getAbsolutePath(), FileUtils.read(newPngFile));
if(img == null) {
/* Should not happen. If so, ImageParser.parse() should already have logged about the error */
return false;
}
final Image scaled = img.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING);
final MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(scaled, 0);

0 comments on commit a17a418

Please sign in to comment.