[JIRA] Commented: (JXT-82) ListView's clear empties the whole backingList instead of only the entries it's responsible for

Brent Putman (JIRA) noreply at shibboleth.net
Fri Oct 21 23:20:26 BST 2011


    [ https://issues.shibboleth.net/jira/browse/JXT-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13664#comment-13664 ] 

Brent Putman commented on JXT-82:
---------------------------------

Note that this is also currently true today:

QName foo  = ...;
IndexedXMLObjectChildrenList indexedXMLChildlist = ....;

# Assuming there are no foo's, this returns null
List list = indexedXMLChildlist.get(foo);

# This returns a logically empty sublist
List sublist = indexedXMLChildlist.sublist(foo);

# This no longer returns null, returns an empty list
List list = indexedXMLChildlist.get(foo);


This side effect and asymmetry seems wrong and further argues for changing the behavior of get(QName) to always return an empty list, and never null.


> ListView's clear empties the whole backingList instead of only the entries it's responsible for
> -----------------------------------------------------------------------------------------------
>
>                 Key: JXT-82
>                 URL: https://issues.shibboleth.net/jira/browse/JXT-82
>             Project: XMLTooling - Java
>          Issue Type: Bug
>    Affects Versions: 1.3.1
>            Reporter: anli.shundi at idp.protectnetwork.org
>            Assignee: Brent Putman
>             Fix For: 1.3.3
>
>
> class {{ListView<ElementType extends XMLObject> extends AbstractList<ElementType>}} inside {{IndexedXMLObjectChildrenList}} overrides the method {{clear()}} of {{java.util.AbstracList}} but violates its javadoc:
> According to http://download.oracle.com/javase/6/docs/api/java/util/AbstractList.html#subList(int,%20int)
> {quote}
> ...the following idiom removes a range of elements from a list:
>       {{list.subList(from, to).clear();}}
> {quote}
> ListView's clear calls {{backingList.clear();}} instead; that is it clears the whole backing list instead of limiting to the QNames it lists itself.  A quick fix would be to call {{backingList.removeAll(this)}} instead.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the commits mailing list