[JIRA] (GLAZEDLISTS-499) GroupingList is throwing an npe

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[JIRA] (GLAZEDLISTS-499) GroupingList is throwing an npe

JIRA jira-no-reply@java.net

    [ https://java.net/jira/browse/GLAZEDLISTS-499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=393916#comment-393916 ]

fabian_ commented on GLAZEDLISTS-499:
-------------------------------------

I just looked into this for a bit:

Since that also compares the grouper I first looked into this test https://github.com/glazedlists/glazedlists/blob/master/test/ca/odell/glazedlists/UniqueListTest.java#L1670 and realized:

When you step through the test, line by line, UniqueList is coming into an inconsistent state when it's source TransactionList is changed within a transaction. Meaning it contains duplicate values like "AAE".
This inconsistent state is cleared after "commitEvent()", but apparently there's a gap for race-conditions. This is also what breaks the test.

> GroupingList is throwing an npe
> -------------------------------
>
>                 Key: GLAZEDLISTS-499
>                 URL: https://java.net/jira/browse/GLAZEDLISTS-499
>             Project: glazedlists
>          Issue Type: Bug
>          Components: core
>    Affects Versions: current
>         Environment: Operating System: All
> Platform: All
>            Reporter: vgoldshteyn
>            Priority: Blocker
>             Fix For: 1.10.0
>
>
> This problem might be related to the
> https://glazedlists.dev.java.net/issues/show_bug.cgi?id=491.
> below is a modified case that breaks the latest build with the patch for issue
> 491.
> thanks for your help
> package sandbox;
> import java.util.Comparator;
> import junit.framework.TestCase;
> import ca.odell.glazedlists.BasicEventList;
> import ca.odell.glazedlists.GroupingList;
> import ca.odell.glazedlists.TransactionList;
> public class test extends TestCase
> {
> protected void setUp() throws Exception
> {
> super.setUp();
> }
> protected void tearDown() throws Exception
> {
> super.tearDown();
> }
> public void testIt()
> {
> TransactionList<String> source = new TransactionList<String>(new
> BasicEventList<String>());
> Comparator<String> comparator = new StringPrefixComparator(1);
> GroupingList<String> grouped = new GroupingList<String>(source,
> comparator);
> String[] s = new
> String[]{"MSFT","MSFT","IBM","C","IBM","C","C","IBM","IBM","C"};
> String[] upd = new
> String[]{"MSFT","MSFT","MSFT","C","C","IBM","IBM","IBM","C","MSFT"};
>
> for( int i = 0; i < s.length; i++ )
> source.add(s[i]);
> System.out.println(grouped.toString());
> source.beginEvent();
> for (int i = 0; i < upd.length; i++)
> source.set(i, upd[i]);
> source.commitEvent();
> System.out.println(grouped.toString());
> }
> private static class StringPrefixComparator implements
> Comparator<String>
> {
> private final int prefixLen;
> public StringPrefixComparator(int prefixLen)
> {
> this.prefixLen = prefixLen;
> }
> public int compare(String o1, String o2)
> {
> return o1.substring(0,
> prefixLen).compareTo(o2.substring(0, prefixLen));
> }
> }
> }



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
Loading...