Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 71425 invoked from network); 7 Apr 2009 08:24:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Apr 2009 08:24:41 -0000 Received: (qmail 72974 invoked by uid 500); 7 Apr 2009 08:24:41 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 72898 invoked by uid 500); 7 Apr 2009 08:24:41 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 72888 invoked by uid 99); 7 Apr 2009 08:24:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2009 08:24:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,FU_LONG_QUERY3 X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2009 08:24:33 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E74E8234C004 for ; Tue, 7 Apr 2009 01:24:12 -0700 (PDT) Message-ID: <1691160728.1239092652932.JavaMail.jira@brutus> Date: Tue, 7 Apr 2009 01:24:12 -0700 (PDT) From: "Julien Kronegg (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-1025) AbstractResultList.subList throws UnsupportedOperationException In-Reply-To: <764459060.1239088452938.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-1025?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Julien Kronegg updated OPENJPA-1025: ------------------------------------ Description: AbstractResultList implements the basics for readonly result lists. When calling the subList(int,int) method, the following exception is raised: java.lang.UnsupportedOperationException at org.apache.openjpa.lib.rop.AbstractResultList.subList(AbstractResultList.java:84) at org.apache.openjpa.kernel.DelegatingResultList.subList(DelegatingResultList.java:308) ... Since the subList() method contract is to create a new List from the ResultList, this operation does not modify the original list: it only provides a *view* on the original list (see http://java.sun.com/docs/books/tutorial/collections/interfaces/list.html ). This problem is also found by other users: http://n2.nabble.com/DelegatingResultList.subList-not-implemented--td210389.html They found the (bad) workaround to build a new List (bad because this is not the same as calling subList()): List mySubList = new ArrayList(openjpaList).subList(from, to); The AbstractResultList class should be modified by one of this solution (sorted by decreasing preference order): 1) the AbstractResultList class should extends java.util.AbstractList and the subList() method should be removed (because implemented by AbstractList) 2) the subList() method should be implemented to return a view on the original list. See java.util.AbstractList for an implementation (http://www.koders.com/java/fidCFCB47A1819AB345234CC04B6A1EA7554C2C17C0.aspx?s=iso+3166 ) 3) the subList() method should throw the exception with the message "this method is not yet implemented. Workaround: new ArrayList(openjpaList).subList(from, to)" was: AbstractResultList implements the basics for readonly result lists. When calling the subList(int,int) method, the following exception is raised: java.lang.UnsupportedOperationException at org.apache.openjpa.lib.rop.AbstractResultList.subList(AbstractResultList.java:84) at org.apache.openjpa.kernel.DelegatingResultList.subList(DelegatingResultList.java:308) ... Since the subList() method contract is to create a new List from the ResultList, this operation does not modify the original list. Thus, the subList() method should not raise an exception but should return a new list such as: return new ArrayList(openjpaList).subList(from, to); This problem is also found by other users: http://n2.nabble.com/DelegatingResultList.subList-not-implemented--td210389.html Remaining Estimate: 4h (was: 2h) Original Estimate: 4h (was: 2h) > AbstractResultList.subList throws UnsupportedOperationException > --------------------------------------------------------------- > > Key: OPENJPA-1025 > URL: https://issues.apache.org/jira/browse/OPENJPA-1025 > Project: OpenJPA > Issue Type: Bug > Components: lib > Affects Versions: 1.2.1, 1.3.0, 2.0.0 > Environment: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java?revision=757278&view=markup, > Seam 2.0, OpenJPA 1.2.1 > Reporter: Julien Kronegg > Original Estimate: 4h > Remaining Estimate: 4h > > AbstractResultList implements the basics for readonly result lists. When calling the subList(int,int) method, the following exception is raised: > java.lang.UnsupportedOperationException > at org.apache.openjpa.lib.rop.AbstractResultList.subList(AbstractResultList.java:84) > at org.apache.openjpa.kernel.DelegatingResultList.subList(DelegatingResultList.java:308) > ... > Since the subList() method contract is to create a new List from the ResultList, this operation does not modify the original list: it only provides a *view* on the original list (see http://java.sun.com/docs/books/tutorial/collections/interfaces/list.html ). > This problem is also found by other users: http://n2.nabble.com/DelegatingResultList.subList-not-implemented--td210389.html > They found the (bad) workaround to build a new List (bad because this is not the same as calling subList()): > List mySubList = new ArrayList(openjpaList).subList(from, to); > The AbstractResultList class should be modified by one of this solution (sorted by decreasing preference order): > 1) the AbstractResultList class should extends java.util.AbstractList and the subList() method should be removed (because implemented by AbstractList) > 2) the subList() method should be implemented to return a view on the original list. See java.util.AbstractList for an implementation (http://www.koders.com/java/fidCFCB47A1819AB345234CC04B6A1EA7554C2C17C0.aspx?s=iso+3166 ) > 3) the subList() method should throw the exception with the message "this method is not yet implemented. Workaround: new ArrayList(openjpaList).subList(from, to)" -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.