Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-1396

DateValue.getDate not a copy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.4
    • 1.5
    • jackrabbit-jcr-commons
    • None
    • any

    Description

      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); }

      Attachments

        Activity

          People

            Unassigned Unassigned
            prehn81 Sebastian Prehn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 0.25h
                0.25h
                Remaining:
                Remaining Estimate - 0.25h
                0.25h
                Logged:
                Time Spent - Not Specified
                Not Specified