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

Maruan Sahyoun commented on PDFBOX-2685:
----------------------------------------

I'll leave it at the current stage and marked it as Critical. We should have a 
discussion after 2.0 is out as how to approach that. There are two options as 
far as I can tell

- keep COSWriter generic and mark the COSObjects from the PDModel - then we 
need to remove caching
- have some knowledge about what needs to be written and it's rule at COSWriter 
level or similar - then we can keep the caching

We need to take a closer look at which objects shall be direct/indirect 
according to the spec as from a first glance there might be some which we mark 
incorrectly - that needs to be done on the PD level. Users using the COS model 
directly are required to have a good knowledge of the PDF spec and need to set 
direct/indirect accordingly.

Although I like the benefits of caching currently I tend towards removing it 
for the benefit of having a simple COS model.

If we want to make the decision now we can move the issue back to 2.0.0.



> COS 'primitive' types are mutable
> ---------------------------------
>
>                 Key: PDFBOX-2685
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2685
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.8.8, 1.8.9, 2.0.0
>            Reporter: Tilman Hausherr
>            Assignee: Maruan Sahyoun
>            Priority: Critical
>             Fix For: 2.1.0
>
>
> From [~torakiki]:
> They are cached and they are mutable so this:
> {code}
>         COSInteger cosint = COSInteger.get(10);
>         cosint.setValue(50);
>         //lets move to a totally unrelated part of my software
>         System.out.println(COSInteger.get(10));
> {code}
> prints COSInteger(50) so basically I ask for a 10 and get a 50, isn't it 
> weird (and error prone)? ... or the way around, I call cosint.setValue(50) at 
> some point in the software and that makes it a 50 everywhere I used 
> COSInteger.get(10).
> That's of course also true for the other mutable attributes setDirect and 
> setNeedToBeUpdate.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to