You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Lucas (Jira)" <ji...@apache.org> on 2023/09/26 17:01:00 UTC
[jira] [Updated] (IMAGING-364) NullPointerException in TiffDirectory.getTiffImage()
[ https://issues.apache.org/jira/browse/IMAGING-364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary Lucas updated IMAGING-364:
-------------------------------
Description:
When calling TiffDirectory.getTiffImage(), Commons Imaging throws a null pointer exception.
{code:java}
java.lang.NullPointerException
at org.apache.commons.imaging.formats.tiff.TiffImageParser.checkForSubImage(TiffImageParser.java:78)
at org.apache.commons.imaging.formats.tiff.TiffImageParser.getBufferedImage(TiffImageParser.java:261)
at org.apache.commons.imaging.formats.tiff.TiffDirectory.getTiffImage(TiffDirectory.java:776){code}
If you call the alternate method TiffDirectory.getTiffImage(TiffImagingParameters), it works okay. The problem is that the internal method TiffImageParser().getBufferedImage() cannot handle a null reference.
Here's the problematic code from TiffDirectory.java
{code:java}
public BufferedImage getTiffImage() throws ImagingException, IOException {
if (null == abstractTiffImageData) {
return null;
}
return new TiffImageParser().getBufferedImage(
this, headerByteOrder, null);
}
{code}
We could either make TiffImageParser more robust, or we could avoid passing in a null value for the third argument.
{code:java}
TiffImagingParameters defaultParameters = new TiffImagingParameters();
return new TiffImageParser().getBufferedImage(
this, headerByteOrder, defaultParameters);{code}
was:
When calling TiffDirectory.getTiffImage(), Commons Imaging throws a null pointer exception. If you call the alternate method TiffDirectory.getTiffImage(TiffImagingParameters), it works okay. The problem is that the internal method TiffImageParser().getBufferedImage() cannot handle a null reference.
Here's the problematic code.
{code:java}
public BufferedImage getTiffImage() throws ImagingException, IOException {
if (null == abstractTiffImageData) {
return null;
}
return new TiffImageParser().getBufferedImage(
this, headerByteOrder, null);
}
{code}
We could either make TiffImageParser more robust, or we could avoid passing in a null value for the third argument.
{code:java}
TiffImagingParameters defaultParameters = new TiffImagingParameters();
return new TiffImageParser().getBufferedImage(
this, headerByteOrder, defaultParameters);{code}
> NullPointerException in TiffDirectory.getTiffImage()
> ----------------------------------------------------
>
> Key: IMAGING-364
> URL: https://issues.apache.org/jira/browse/IMAGING-364
> Project: Commons Imaging
> Issue Type: Bug
> Components: Format: TIFF
> Affects Versions: 1.0-alpha3
> Reporter: Gary Lucas
> Priority: Major
>
> When calling TiffDirectory.getTiffImage(), Commons Imaging throws a null pointer exception.
> {code:java}
> java.lang.NullPointerException
> at org.apache.commons.imaging.formats.tiff.TiffImageParser.checkForSubImage(TiffImageParser.java:78)
> at org.apache.commons.imaging.formats.tiff.TiffImageParser.getBufferedImage(TiffImageParser.java:261)
> at org.apache.commons.imaging.formats.tiff.TiffDirectory.getTiffImage(TiffDirectory.java:776){code}
>
> If you call the alternate method TiffDirectory.getTiffImage(TiffImagingParameters), it works okay. The problem is that the internal method TiffImageParser().getBufferedImage() cannot handle a null reference.
>
> Here's the problematic code from TiffDirectory.java
> {code:java}
> public BufferedImage getTiffImage() throws ImagingException, IOException {
> if (null == abstractTiffImageData) {
> return null;
> }
> return new TiffImageParser().getBufferedImage(
> this, headerByteOrder, null);
> }
> {code}
>
> We could either make TiffImageParser more robust, or we could avoid passing in a null value for the third argument.
>
> {code:java}
> TiffImagingParameters defaultParameters = new TiffImagingParameters();
> return new TiffImageParser().getBufferedImage(
> this, headerByteOrder, defaultParameters);{code}
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)