1
0
mirror of https://github.com/yacy/yacy_search_server.git synced 2025-07-19 08:44:42 -04:00

Fixed NullPointerException cases on snapshot images parsing.

This commit is contained in:
luccioman
2017-10-18 08:31:18 +02:00
parent 285f0d6a39
commit a17a418e78
2 changed files with 9 additions and 1 deletions
htroot/api
source/net/yacy/cora/util

@ -304,6 +304,10 @@ public class snapshot {
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 class Html2Image {
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);