Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-20

List returned by cursor.toArray() can not be modified

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.8
    • Affects Version/s: None
    • Component/s: None
    • None

      The list object returned by calling the toArray() function is not modifiable.

      E.g.

      Collections.sort(values, myCustomSorter);
      List<DBObject> values = cursor.toArray();

      Causes an unsupported operation exception:

      Caused by: java.lang.UnsupportedOperationException
      at java.util.Collections$UnmodifiableList$1.set(Collections.java:1186)
      at java.util.Collections.sort(Collections.java:163)

      The source for DBCursor shows:

      Collections.unmodifiableList( _all );

      Why is this list unmodifiable? I want to sot my data in the application layer instead of taxing Mongo with this.

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            rn@deftlabs.com Ryan Nitz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: