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

John Hewson edited comment on PDFBOX-2505 at 11/27/14 8:30 PM:
---------------------------------------------------------------

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 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.


was (Author: jahewson):
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.<init>(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)

Reply via email to