[ http://jira.magnolia.info/browse/MAGNOLIA-2377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18017#action_18017 ]
Gregory Joseph commented on MAGNOLIA-2377: ------------------------------------------ If you look at the [Property.getDate() javadoc|http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Property.html#getDate()] it says: bq. The object returned is a copy of the stored value, so changes to it are not reflected in internal storage. This is misleading, because I would thus expect the above snippet to show that we get a fresh copy every time we do getProperty on the node. Instead, if you look at the Jackrabbit code, you'll see that the {{Value}} implementation holds a cache of a Calendar instance, and (I'm only guessing here: ), the {{Node}} implementation probably also holds a cache of its associated {{Value}}s. I'll actually keep this open to gather some feedback - should this be considered a Jackrabbit issue ? > Issue with getDate() > -------------------- > > Key: MAGNOLIA-2377 > URL: http://jira.magnolia.info/browse/MAGNOLIA-2377 > Project: Magnolia > Issue Type: Bug > Components: templating > Affects Versions: 3.5.4 > Reporter: Olivier Marti > Assignee: Gregory Joseph > > It seems that for a Value in the repository of the value "Date" only one copy > is existing in the memory, where all queries to it are referencing. > This is bad, in cases I want to manipulate the date (like compare today with > a timespan from two weeks before till the actual value in the node). > That's what my code looks like: > Content activeNode= Resource.getLocalContentNode(); > Calendar orig = activeNode.getNodeData("date").getDate(); > System.out.println("orig: " + orig.getTime()); > Calendar moduleDate = activeNode.getNodeData("date").getDate(); > moduleDate.add(Calendar.DATE,-14); > System.out.println("modified: " + moduleDate.getTime()); > Calendar reloaded = activeNode.getNodeData("date").getDate(); > System.out.println("reloaded: " + reloaded.getTime()); > Result: > orig: Wed Oct 15 14:30:00 CEST 2008 > modified: Wed Oct 01 14:30:00 CEST 2008 > reloaded: Wed Oct 01 14:30:00 CEST 2008 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.magnolia.info/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ---------------------------------------------------------------- for list details see http://documentation.magnolia.info/ ----------------------------------------------------------------