DateValue.getDate not a copy
----------------------------
Key: JCR-1396
URL: https://issues.apache.org/jira/browse/JCR-1396
Project: Jackrabbit
Issue Type: Bug
Components: jackrabbit-jcr-commons
Affects Versions: 1.4
Environment: any
Reporter: Sebastian Prehn
I noticed that getDate() in org.apache.jackrabbit.value.DateValue is returned
by reference. According to the specification it should be a copy. (see. JSR
170 section 6.2.7)
private Calendar date;
public Calendar getDate()
throws ValueFormatException, IllegalStateException,
RepositoryException {
setValueConsumed();
if (date != null) {
return date; // <-- HERE
} else {
throw new ValueFormatException("empty value");
}
}
short test:
ValueFactory factory = session.getValueFactory();
Value v = factory.createValue(GregorianCalendar.getInstance());
Calendar c0 = v.getDate();
Calendar c1 = v.getDate();
if(c0 == c1){
out.println("error - references are equal");
out.println(c0);
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.