You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Bernhard Fey <E-...@web.de> on 2009/04/29 11:22:29 UTC
Exception in COSArray.getInt, including fix
Hi,
I have found the following Exception when experimenting with the PDFBox
trunk:
java.lang.ClassCastException: org.apache.pdfbox.cos.COSNull
at org.apache.pdfbox.cos.COSArray.getInt(COSArray.java:240)
at org.apache.pdfbox.cos.COSArray.getInt(COSArray.java:224)
at
org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageX
YZDestination.getLeft(PDPageXYZDestination.java:67)
at ...
As a fix I have changed the method from
------------------------------------------------------
public int getInt( int index, int defaultValue )
{
int retval = defaultValue;
if( defaultValue < size() )
{
COSNumber number = (COSNumber)get( index );
if( number != null )
{
retval = number.intValue();
}
}
return retval;
}
------------------------------------------------------
to
------------------------------------------------------
public int getInt( int index, int defaultValue )
{
int retval = defaultValue;
if( defaultValue < size() )
{
Object number = get( index );
if( number != null && number instanceof COSNumber )
{
retval = ((COSNumber)number).intValue();
}
}
return retval;
}
------------------------------------------------------
.
I was wondering whether this was the best solution for this issue.
If it is, could you please add it to the SVN trunk?
Thanks
Bernhard
Re: Exception in COSArray.getInt, including fix
Posted by Andreas Lehmkühler <an...@lehmi.de>.
Hi Bernhard,
your patch shows the right direction but has to be modified to remove
all issues at that part of the code. See [1] for more details.
Thanks for your help!!
Andreas Lehmkühler
[1] https://issues.apache.org/jira/browse/PDFBOX-458
Bernhard Fey schrieb:
> Hi,
>
> I have found the following Exception when experimenting with the PDFBox
> trunk:
>
> java.lang.ClassCastException: org.apache.pdfbox.cos.COSNull
> at org.apache.pdfbox.cos.COSArray.getInt(COSArray.java:240)
> at org.apache.pdfbox.cos.COSArray.getInt(COSArray.java:224)
> at
> org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageX
> YZDestination.getLeft(PDPageXYZDestination.java:67)
> at ...
>
> As a fix I have changed the method from
> ------------------------------------------------------
> public int getInt( int index, int defaultValue )
> {
> int retval = defaultValue;
> if( defaultValue < size() )
> {
> COSNumber number = (COSNumber)get( index );
> if( number != null )
> {
> retval = number.intValue();
> }
> }
> return retval;
> }
> ------------------------------------------------------
> to
> ------------------------------------------------------
> public int getInt( int index, int defaultValue )
> {
> int retval = defaultValue;
> if( defaultValue < size() )
> {
> Object number = get( index );
> if( number != null && number instanceof COSNumber )
> {
> retval = ((COSNumber)number).intValue();
> }
> }
> return retval;
> }
> ------------------------------------------------------
> .
>
> I was wondering whether this was the best solution for this issue.
>
> If it is, could you please add it to the SVN trunk?
>
> Thanks
>
> Bernhard
>
>