jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebastian Prehn (JIRA)" <j...@apache.org>
Subject [jira] Created: (JCR-1396) DateValue.getDate not a copy
Date Tue, 19 Feb 2008 13:04:45 GMT
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 {
         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");

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message