[JAVA-20] List returned by cursor.toArray() can not be modified Created: 12/Aug/09  Updated: 02/Oct/09  Resolved: 17/Aug/09

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 0.8

Type: Bug Priority: Major - P3
Reporter: Ryan Nitz Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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.


Generated at Thu Feb 08 08:51:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.