[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-12-09 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14239866#comment-14239866
 ] 

ASF subversion and git services commented on PDFBOX-2505:
-

Commit 1644156 from [~tilman] in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1644156 ]

PDFBOX-2505: fix parameter validation from previous commit

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-28 Thread John Hewson (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14228480#comment-14228480
 ] 

John Hewson commented on PDFBOX-2505:
-

No, that's ok though, I'm always happy to advocate the general principles of 
careful API design. Looks like we're on the same page already :)

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-27 Thread Tilman Hausherr (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227972#comment-14227972
 ] 

Tilman Hausherr commented on PDFBOX-2505:
-

Are you aware that I just added a call to that validator in an operator that is 
unrelated to setColor?

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-27 Thread John Hewson (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227948#comment-14227948
 ] 

John Hewson commented on PDFBOX-2505:
-

But it might not prove to be a good API choice for a future, more general 
problem, for example it's already changed from checking {{\!=}} to checking 
{{>=}}. You can always add more abstraction when you need it, and move the 
method up to a OperatorProcessor from SetColor, but going the other way is a 
breaking API change! So adding abstraction which you don't need yet is a code 
smell, as you can easily get stuck with an API which turns out not to be as 
general as you need it to be when you actually come to solve the future problem.

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-27 Thread Tilman Hausherr (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227877#comment-14227877
 ] 

Tilman Hausherr commented on PDFBOX-2505:
-

Thanks; I put checkArgumentSize in OperatorProcessor with the thought that we'd 
have more such validators in the future.

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-27 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227876#comment-14227876
 ] 

ASF subversion and git services commented on PDFBOX-2505:
-

Commit 1642199 from [~tilman] in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1642199 ]

PDFBOX-2505: @return no longer needed

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-27 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227875#comment-14227875
 ] 

ASF subversion and git services commented on PDFBOX-2505:
-

Commit 1642198 from [~tilman] in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1642198 ]

PDFBOX-2505: parameter validation as minimum, code cleanup

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-27 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227873#comment-14227873
 ] 

ASF subversion and git services commented on PDFBOX-2505:
-

Commit 1642196 from [~tilman] in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1642196 ]

PDFBOX-2505: parameter validation

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-27 Thread John Hewson (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227857#comment-14227857
 ] 

John Hewson commented on PDFBOX-2505:
-

The method {{checkArgumentSize}} doesn't really belong in OperatorProcessor as 
it isn't used elsewhere, it would be better to move it to SetColor to avoid 
unnecessary abstraction. Also what happens to colours which have _too many_ 
components, couldn't these be truncated rather than ignored?


On last, thing, regarding the following change:
{code}
 /**
  * Returns the name of this operator, e.g. "BI".
+ * @return operator name.
  */
 public abstract String getName();
{code}


You don't need to worry about adding @return for simple getters, or any case 
where the text is essentially a duplicate of the description. The [Google Java 
Style 
Guide|https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s7.2-summary-fragment]
 briefly mentions this, and it's becoming a standard practice now in newer Java 
codebases.

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-26 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227332#comment-14227332
 ] 

ASF subversion and git services commented on PDFBOX-2505:
-

Commit 1642033 from [~tilman] in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1642033 ]

PDFBOX-2505: parameter validation for the device colorspace operators; code 
cleanup

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in PDColor constructor

2014-11-18 Thread John Hewson (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14216779#comment-14216779
 ] 

John Hewson commented on PDFBOX-2505:
-

Invalid operators/operands are usually just skipped. Unless the PDF fails to 
render, that's what I'd do.

> ArrayIndexOutOfBoundsException in PDColor constructor
> -
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Affects Versions: 2.0.0
>Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at 
> org.apache.pdfbox.pdmodel.graphics.color.PDColor.(PDColor.java:54)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at 
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes 
> the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 
> SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another 
> constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array 
> size and would also change the other constructor)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)