commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <>
Subject [jira] Commented: (IO-191) Possible improvements using static analysis.
Date Thu, 22 Jan 2009 13:03:59 GMT


Jukka Zitting commented on IO-191:

Responding to Sebb's comment first.

If one thread creates a new collection whilst another is iterating it, then in the absence
of synchronisation there is no guarantee what state the other thread will next see for the

Not true. For example, consider the following pseudocode where two threads, A and B, concurrently
access the same collection.

A: iterator = collection.iterator();
B: collection = new Collection();

A continues to see the contents of the original collection while iterating, which IMHO is
the only reasonable and deterministic behaviour in such cases. If thread B use collection.clear(),
thread A would likely fail with a ConcurrentModificationException.

However, my objection applies only to cases where the collection is immutable after initialization
(otherwise the threads would in any case need to worry about synchronization). In AndFileFilter
this is not the case, so there I think using Collection.clear() is actually a valid option.
This context is not visible in the patch, so I'd rather consider such changes on a case-by-case
basis instead of as a part of a bigger changeset generated by an analyzer tool.

> Possible improvements using static analysis.
> --------------------------------------------
>                 Key: IO-191
>                 URL:
>             Project: Commons IO
>          Issue Type: Improvement
>            Reporter: Peter Lawrey
>            Priority: Trivial
>         Attachments: commons-io-static-analysis.patch
>   Original Estimate: 3h
>  Remaining Estimate: 3h

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message