Quantcast

NullPointerException in BarcodeNode

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

NullPointerException in BarcodeNode

eric
Hi all,

I'm running into an issue using GlazedLists 1.9.1 in my application that results in a NullPointerException being thrown. I've attempted to distill down the code to simple main class that can reproduce the error.

import java.util.*;
import ca.odell.glazedlists.*;

public class NullPointerScenario
{
    private final SeparatorList theSeparatorList;
    private final EventList theModel;

    public static void main(String[] anArguments)
    {
        new NullPointerScenario().doSomething();
    }

    public NullPointerScenario()
    {
        theModel = new BasicEventList<>();
        theSeparatorList = new SeparatorList<>(theModel, createComparator(), 0, 0);
        theSeparatorList.setComparator(createComparator());
    }

    private Comparator createComparator()
    {
        return new Comparator()
        {
            @Override
            public int compare(Object o1, Object o2)
            {
                return 0;
            }
        };
    }

    public void doSomething()
    {
        theModel.add(new Object());
        theModel.add(new Object());
    }
}

The example is adding two objects to the same group of a SeparatorList that is collapsed by default. It looks odd, but setting the comparator a second time was required to reproduce this. It is necessary because the comparator can be dynamically changed in the application. Let me know if there's any additional info I can provide. Thanks in advance for having a look!

The exception received is:

Exception in thread "main" java.lang.NullPointerException
        at ca.odell.glazedlists.impl.adt.BarcodeNode.insertWhite(BarcodeNode.java:158)
        at ca.odell.glazedlists.impl.adt.Barcode.addWhite(Barcode.java:137)
        at ca.odell.glazedlists.impl.adt.BarcodeNode.unlink(BarcodeNode.java:762)
        at ca.odell.glazedlists.impl.adt.BarcodeNode.unlink(BarcodeNode.java:734)
        at ca.odell.glazedlists.impl.adt.BarcodeNode.setBaseCase(BarcodeNode.java:584)
        at ca.odell.glazedlists.impl.adt.BarcodeNode.set(BarcodeNode.java:437)
        at ca.odell.glazedlists.impl.adt.Barcode.set(Barcode.java:203)
        at ca.odell.glazedlists.SeparatorList.setVisible(SeparatorList.java:374)
        at ca.odell.glazedlists.SeparatorList.updateGroup(SeparatorList.java:355)
        at ca.odell.glazedlists.SeparatorList.listChanged(SeparatorList.java:307)
        at ca.odell.glazedlists.event.ListEventAssembler$ListEventFormat.fire(ListEventAssembler.java:424)
        at ca.odell.glazedlists.event.ListEventAssembler$ListEventFormat.fire(ListEventAssembler.java:421)
        at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher$SubjectAndListener.firePendingEvent(SequenceDependenciesEventPublisher.java:445)
        at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher.fireEvent(SequenceDependenciesEventPublisher.java:344)
        at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:317)
        at ca.odell.glazedlists.BasicEventList.add(BasicEventList.java:142)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NullPointerException in BarcodeNode

eric
I figured out why this is happening. When setting a new comparator on the SeparatorList it will fire an event that removes and re-inserts all elements. This event is picked up by the SeparatorInjectorList. The SeparatorInjectorList always checks if there is a new comparator and if there is it rebuilds the groups and bails out. If the list is empty when we set the comparator, no event is fired. The SeparatorInjectorList doesn't rebuild the groups until the next insert event. It then bails out before it fires another event and won't update the collapsed elements in the SeparatorList. If the list is empty we should still be able to fire a no-op event to notify that the comparator changed.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NullPointerException in BarcodeNode

James Lemieux
Hey Eric, I'll try to take a look at this tonight.

On Thu, Jun 4, 2015 at 10:13 AM, eric <[hidden email]> wrote:
I figured out why this is happening. When setting a new comparator on the
SeparatorList it will fire an event that removes and re-inserts all
elements. This event is picked up by the SeparatorInjectorList. The
SeparatorInjectorList always checks if there is a new comparator and if
there is it rebuilds the groups and bails out. If the list is empty when we
set the comparator, no event is fired. The SeparatorInjectorList doesn't
rebuild the groups until the next insert event. It then bails out before it
fires another event and won't update the collapsed elements in the
SeparatorList. If the list is empty we should still be able to fire a no-op
event to notify that the comparator changed.



--
View this message in context: http://glazedlists.1045722.n5.nabble.com/NullPointerException-in-BarcodeNode-tp5710248p5710252.html
Sent from the GlazedLists - Dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NullPointerException in BarcodeNode

James Lemieux
Hey Eric,

   I have checked in a fix which solves your bug. I'll ask my partner-in-crime, Holger, to update our snapshot build for you at his earliest convenience.

   Thanks for taking the time to distill such a targeted repro case. It is appreciated.

James

On Thu, Jun 4, 2015 at 3:29 PM, James Lemieux <[hidden email]> wrote:
Hey Eric, I'll try to take a look at this tonight.

On Thu, Jun 4, 2015 at 10:13 AM, eric <[hidden email]> wrote:
I figured out why this is happening. When setting a new comparator on the
SeparatorList it will fire an event that removes and re-inserts all
elements. This event is picked up by the SeparatorInjectorList. The
SeparatorInjectorList always checks if there is a new comparator and if
there is it rebuilds the groups and bails out. If the list is empty when we
set the comparator, no event is fired. The SeparatorInjectorList doesn't
rebuild the groups until the next insert event. It then bails out before it
fires another event and won't update the collapsed elements in the
SeparatorList. If the list is empty we should still be able to fire a no-op
event to notify that the comparator changed.



--
View this message in context: http://glazedlists.1045722.n5.nabble.com/NullPointerException-in-BarcodeNode-tp5710248p5710252.html
Sent from the GlazedLists - Dev mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NullPointerException in BarcodeNode

hbrands
Administrator
Hey James,

did you push your changes back to github?
I don't see them there yet...

Holger


2015-06-06 13:20 GMT+02:00 James Lemieux <[hidden email]>:
Hey Eric,

   I have checked in a fix which solves your bug. I'll ask my partner-in-crime, Holger, to update our snapshot build for you at his earliest convenience.

   Thanks for taking the time to distill such a targeted repro case. It is appreciated.

James

On Thu, Jun 4, 2015 at 3:29 PM, James Lemieux <[hidden email]> wrote:
Hey Eric, I'll try to take a look at this tonight.

On Thu, Jun 4, 2015 at 10:13 AM, eric <[hidden email]> wrote:
I figured out why this is happening. When setting a new comparator on the
SeparatorList it will fire an event that removes and re-inserts all
elements. This event is picked up by the SeparatorInjectorList. The
SeparatorInjectorList always checks if there is a new comparator and if
there is it rebuilds the groups and bails out. If the list is empty when we
set the comparator, no event is fired. The SeparatorInjectorList doesn't
rebuild the groups until the next insert event. It then bails out before it
fires another event and won't update the collapsed elements in the
SeparatorList. If the list is empty we should still be able to fire a no-op
event to notify that the comparator changed.



--
View this message in context: http://glazedlists.1045722.n5.nabble.com/NullPointerException-in-BarcodeNode-tp5710248p5710252.html
Sent from the GlazedLists - Dev mailing list archive at Nabble.com.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NullPointerException in BarcodeNode

James Lemieux
whoops... I think I only checked them in locally... I'll upload them tonight. My bad.

On Tue, Jun 9, 2015 at 4:19 AM, Holger Brands <[hidden email]> wrote:
Hey James,

did you push your changes back to github?
I don't see them there yet...

Holger


2015-06-06 13:20 GMT+02:00 James Lemieux <[hidden email]>:
Hey Eric,

   I have checked in a fix which solves your bug. I'll ask my partner-in-crime, Holger, to update our snapshot build for you at his earliest convenience.

   Thanks for taking the time to distill such a targeted repro case. It is appreciated.

James

On Thu, Jun 4, 2015 at 3:29 PM, James Lemieux <[hidden email]> wrote:
Hey Eric, I'll try to take a look at this tonight.

On Thu, Jun 4, 2015 at 10:13 AM, eric <[hidden email]> wrote:
I figured out why this is happening. When setting a new comparator on the
SeparatorList it will fire an event that removes and re-inserts all
elements. This event is picked up by the SeparatorInjectorList. The
SeparatorInjectorList always checks if there is a new comparator and if
there is it rebuilds the groups and bails out. If the list is empty when we
set the comparator, no event is fired. The SeparatorInjectorList doesn't
rebuild the groups until the next insert event. It then bails out before it
fires another event and won't update the collapsed elements in the
SeparatorList. If the list is empty we should still be able to fire a no-op
event to notify that the comparator changed.



--
View this message in context: http://glazedlists.1045722.n5.nabble.com/NullPointerException-in-BarcodeNode-tp5710248p5710252.html
Sent from the GlazedLists - Dev mailing list archive at Nabble.com.




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NullPointerException in BarcodeNode

James Lemieux
Changes pushed to github. Go ahead, Holger.

On Tue, Jun 9, 2015 at 11:15 AM, James Lemieux <[hidden email]> wrote:
whoops... I think I only checked them in locally... I'll upload them tonight. My bad.

On Tue, Jun 9, 2015 at 4:19 AM, Holger Brands <[hidden email]> wrote:
Hey James,

did you push your changes back to github?
I don't see them there yet...

Holger


2015-06-06 13:20 GMT+02:00 James Lemieux <[hidden email]>:
Hey Eric,

   I have checked in a fix which solves your bug. I'll ask my partner-in-crime, Holger, to update our snapshot build for you at his earliest convenience.

   Thanks for taking the time to distill such a targeted repro case. It is appreciated.

James

On Thu, Jun 4, 2015 at 3:29 PM, James Lemieux <[hidden email]> wrote:
Hey Eric, I'll try to take a look at this tonight.

On Thu, Jun 4, 2015 at 10:13 AM, eric <[hidden email]> wrote:
I figured out why this is happening. When setting a new comparator on the
SeparatorList it will fire an event that removes and re-inserts all
elements. This event is picked up by the SeparatorInjectorList. The
SeparatorInjectorList always checks if there is a new comparator and if
there is it rebuilds the groups and bails out. If the list is empty when we
set the comparator, no event is fired. The SeparatorInjectorList doesn't
rebuild the groups until the next insert event. It then bails out before it
fires another event and won't update the collapsed elements in the
SeparatorList. If the list is empty we should still be able to fire a no-op
event to notify that the comparator changed.



--
View this message in context: http://glazedlists.1045722.n5.nabble.com/NullPointerException-in-BarcodeNode-tp5710248p5710252.html
Sent from the GlazedLists - Dev mailing list archive at Nabble.com.





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NullPointerException in BarcodeNode

hbrands
Administrator

2015-06-10 9:02 GMT+02:00 James Lemieux <[hidden email]>:
Changes pushed to github. Go ahead, Holger.

On Tue, Jun 9, 2015 at 11:15 AM, James Lemieux <[hidden email]> wrote:
whoops... I think I only checked them in locally... I'll upload them tonight. My bad.

On Tue, Jun 9, 2015 at 4:19 AM, Holger Brands <[hidden email]> wrote:
Hey James,

did you push your changes back to github?
I don't see them there yet...

Holger


2015-06-06 13:20 GMT+02:00 James Lemieux <[hidden email]>:
Hey Eric,

   I have checked in a fix which solves your bug. I'll ask my partner-in-crime, Holger, to update our snapshot build for you at his earliest convenience.

   Thanks for taking the time to distill such a targeted repro case. It is appreciated.

James

On Thu, Jun 4, 2015 at 3:29 PM, James Lemieux <[hidden email]> wrote:
Hey Eric, I'll try to take a look at this tonight.

On Thu, Jun 4, 2015 at 10:13 AM, eric <[hidden email]> wrote:
I figured out why this is happening. When setting a new comparator on the
SeparatorList it will fire an event that removes and re-inserts all
elements. This event is picked up by the SeparatorInjectorList. The
SeparatorInjectorList always checks if there is a new comparator and if
there is it rebuilds the groups and bails out. If the list is empty when we
set the comparator, no event is fired. The SeparatorInjectorList doesn't
rebuild the groups until the next insert event. It then bails out before it
fires another event and won't update the collapsed elements in the
SeparatorList. If the list is empty we should still be able to fire a no-op
event to notify that the comparator changed.



--
View this message in context: http://glazedlists.1045722.n5.nabble.com/NullPointerException-in-BarcodeNode-tp5710248p5710252.html
Sent from the GlazedLists - Dev mailing list archive at Nabble.com.






Loading...