You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Blake Sullivan (JIRA)" <de...@myfaces.apache.org> on 2008/10/07 03:27:44 UTC
[jira] Created: (TRINIDAD-1251) Work-around buggy implementation of
Collections.checkedList(), Collections.synchronizedList(),
Collections.unmodifiableList()
Work-around buggy implementation of Collections.checkedList(), Collections.synchronizedList(), Collections.unmodifiableList()
-----------------------------------------------------------------------------------------------------------------------------
Key: TRINIDAD-1251
URL: https://issues.apache.org/jira/browse/TRINIDAD-1251
Project: MyFaces Trinidad
Issue Type: Bug
Affects Versions: 1.2.9-core, 1.2.10-core
Environment: all
Reporter: Blake Sullivan
CollectionUtils.getSerializableList() attempt to optimize its behavior by only wrapping the List if the passed in backing List does not implement Serializable. However, Collections.checkedList(), Collections.synchronizedList(), Collections.unmodifiableList() are all implemented incorrectly with regard to Serialization. The implementation classes used always implement Serializable regardless of whether the supplied backing List is itself Serializable. This results in CollectionUtils.getSerializableList() not attempting to wrap the resulting List and thus Serialization errors.
Two solutions are provided:
1) A new function that always wraps is now provided:
/**
* Returns a List based on the passed in List <code>l</code>,
* guaranteed to be Serializable. List <code>l</code> will be
* wrapped in a List that implements Serializable and upon
* Serialization the contents of <code>l</code> will be copied into
* the result.
* <p>
* If <code>l</code> implements RandomAccess, any returned List will also
* implement RandomAccess.
* <p>
* The results is very similar to creating a new ArrayList with the
* contents of <code>l</code>, but no wrapper is created unless necessary
* and the actual creation of the Serializable copy is deferred until
* Serialization occurs.
* <p>
* Code that calls List.subList() and needs the result to be Serializable should always
* use <code>newSerializableList</code> rather than <code>getSerializableList</code> because
* the <code>java.util.Collections</code> implementations of <code>checkedList</code>,
* <code>unmodifiableList</code>, and <code>synchronizedList</code> all lie and always implement
* Serializable, regardless of the serializability of their backing List.
* @param l The List to get a Serializable version of
* @return A Serializable version of List <code>l</code>
* @see #getSerializableList
* @see #getSerializableCollection
*/
public static <T> List<T> newSerializableList(List<T> l)
2) The implementation of public static <T> List<T> getSerializableList(List<T> l) has been changed to always wrap the result if the backing list was generated by Collections.checkedList(), Collections.synchronizedList() or Collections.unmodifiableList()
In addition, the previous calls to Collectionutils.getSerializableList() are changed to CollectionUtils.newSerializableList() and the support for whitespace between the commas was removed, since it won't work when the System property is specified on the command line
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (TRINIDAD-1251) Work-around buggy implementation
of Collections.checkedList(), Collections.synchronizedList(),
Collections.unmodifiableList()
Posted by "Matthias Weßendorf (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/TRINIDAD-1251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matthias Weßendorf resolved TRINIDAD-1251.
------------------------------------------
Resolution: Fixed
Fix Version/s: 1.2.10-core
Assignee: Matthias Weßendorf
> Work-around buggy implementation of Collections.checkedList(), Collections.synchronizedList(), Collections.unmodifiableList()
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: TRINIDAD-1251
> URL: https://issues.apache.org/jira/browse/TRINIDAD-1251
> Project: MyFaces Trinidad
> Issue Type: Bug
> Affects Versions: 1.2.9-core, 1.2.10-core
> Environment: all
> Reporter: Blake Sullivan
> Assignee: Matthias Weßendorf
> Fix For: 1.2.10-core
>
> Attachments: JIRA_1251_1291.patch
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> CollectionUtils.getSerializableList() attempt to optimize its behavior by only wrapping the List if the passed in backing List does not implement Serializable. However, Collections.checkedList(), Collections.synchronizedList(), Collections.unmodifiableList() are all implemented incorrectly with regard to Serialization. The implementation classes used always implement Serializable regardless of whether the supplied backing List is itself Serializable. This results in CollectionUtils.getSerializableList() not attempting to wrap the resulting List and thus Serialization errors.
> Two solutions are provided:
> 1) A new function that always wraps is now provided:
> /**
> * Returns a List based on the passed in List <code>l</code>,
> * guaranteed to be Serializable. List <code>l</code> will be
> * wrapped in a List that implements Serializable and upon
> * Serialization the contents of <code>l</code> will be copied into
> * the result.
> * <p>
> * If <code>l</code> implements RandomAccess, any returned List will also
> * implement RandomAccess.
> * <p>
> * The results is very similar to creating a new ArrayList with the
> * contents of <code>l</code>, but no wrapper is created unless necessary
> * and the actual creation of the Serializable copy is deferred until
> * Serialization occurs.
> * <p>
> * Code that calls List.subList() and needs the result to be Serializable should always
> * use <code>newSerializableList</code> rather than <code>getSerializableList</code> because
> * the <code>java.util.Collections</code> implementations of <code>checkedList</code>,
> * <code>unmodifiableList</code>, and <code>synchronizedList</code> all lie and always implement
> * Serializable, regardless of the serializability of their backing List.
> * @param l The List to get a Serializable version of
> * @return A Serializable version of List <code>l</code>
> * @see #getSerializableList
> * @see #getSerializableCollection
> */
> public static <T> List<T> newSerializableList(List<T> l)
> 2) The implementation of public static <T> List<T> getSerializableList(List<T> l) has been changed to always wrap the result if the backing list was generated by Collections.checkedList(), Collections.synchronizedList() or Collections.unmodifiableList()
> In addition, the previous calls to Collectionutils.getSerializableList() are changed to CollectionUtils.newSerializableList() and the support for whitespace between the commas was removed, since it won't work when the System property is specified on the command line
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.