It is not clear if ImageResource itself should be null (if image is not found) or ImageResource should be constructed containing a null image, e.g. new ImageResource("lorem.jpg", null).
-
In
|
ImageResource imageResource = docx4jUserAgent.getImageResource(url); |
|
if (imageResource == null) { |
|
// in case of wrong URL - docx4JFSImage will be null |
|
log.error("Couldn't fetch " + url); |
|
} else { |
it seems that the ImageResource must not contain a null image, actually a NullPointerException would be thrown if an ImageResource provides a null image in
|
log.error("Unexpected FSImage class " + fsImage.getClass().getName() ); |
-
However in
|
FSImage fsImage = uac.getImageResource(e.getAttribute("src")).getImage(); |
|
if (fsImage != null) { |
a NullPointerException is thrown if getImageResource returns null - instead the if suggests that ImageResources may contain a null image.
I would suggest to improve null-safety (maybe just allow both cases for both classes)?
It is not clear if
ImageResourceitself should be null (if image is not found) or ImageResource should be constructed containing a null image, e.g.new ImageResource("lorem.jpg", null).In
docx4j-ImportXHTML/docx4j-ImportXHTML-core/src/main/java/org/docx4j/convert/in/xhtml/XHTMLImageHandlerDefault.java
Lines 104 to 108 in ad5d43e
ImageResourcemust not contain anullimage, actually aNullPointerExceptionwould be thrown if anImageResourceprovides anullimage indocx4j-ImportXHTML/docx4j-ImportXHTML-core/src/main/java/org/docx4j/convert/in/xhtml/XHTMLImageHandlerDefault.java
Line 113 in ad5d43e
However in
docx4j-ImportXHTML/docx4j-ImportXHTML-core/src/main/java/org/docx4j/convert/in/xhtml/renderer/Docx4jReplacedElementFactory.java
Lines 57 to 58 in ad5d43e
NullPointerExceptionis thrown ifgetImageResourcereturnsnull- instead the if suggests thatImageResources may contain anullimage.I would suggest to improve null-safety (maybe just allow both cases for both classes)?