I already spent a couple of hours trying to debug this problem, but I was unsuccessful. This is an 'old GUI builder' project, but it doesn't seem to be related to GUI builder in any case.
Here's how I get to the exception. On my main Form there is an InfiniteContainer which has many containers. Clicking a Button on one of these Containers brings the user to the next Form. In the beforeShow method of the second Form, I make a network call to get data related to that Form, using NetworkManager.getInstance().addToQueueAndWait(). This somehow ends up triggering the addMoreComponents() method of the InfiniteScrollAdapter, which throws the exception because the list items it receives are all null.
The first time I press the button, the second Form doesn't open, instead I get this:
java.lang.NullPointerException
at com.codename1.components.InfiniteScrollAdapter.addMoreComponents(InfiniteScrollAdapter.java:156)
at com.codename1.components.InfiniteScrollAdapter.addMoreComponents(InfiniteScrollAdapter.java:143)
at com.codename1.ui.InfiniteContainer.fetchMore(InfiniteContainer.java:156)
at com.codename1.ui.InfiniteContainer$5.run(InfiniteContainer.java:172)
at com.codename1.ui.Display.processSerialCalls(Display.java:1152)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1096)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1205)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1242)
at com.codename1.io.NetworkManager.addToQueueAndWait(NetworkManager.java:619)
at userclasses.BackendConnector.setThreadListMetadata(BackendConnector.java:1012)
at userclasses.StateMachine.beforeForumForm(StateMachine.java:643)
at generated.StateMachineBase.beforeShow(StateMachineBase.java:3367)
at com.codename1.ui.util.UIBuilder.showForm(UIBuilder.java:2518)
at com.codename1.ui.util.UIBuilder.showForm(UIBuilder.java:2565)
at userclasses.modelsandrenderers.ForumListRenderer$2.actionPerformed(ForumListRenderer.java:163)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349)
at com.codename1.ui.Button.fireActionEvent(Button.java:415)
at com.codename1.ui.Button.released(Button.java:446)
at com.codename1.ui.Button.pointerReleased(Button.java:534)
at com.codename1.ui.Form.pointerReleased(Form.java:2642)
at com.codename1.ui.Component.pointerReleased(Component.java:3235)
at com.codename1.ui.Display.handleEvent(Display.java:2023)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1068)
at com.codename1.ui.Display.mainEDTLoop(Display.java:997)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
The second time I press, it works fine.
UPDATE:
I tried running the function in invokeAndBlock(), but there was no change. If the InfiniteContainer has no more items to add, then the exception doesn't occur (i.e. if I first scroll to the end of the InfiniteContainer until it runs out of items to load).
I already spent a couple of hours trying to debug this problem, but I was unsuccessful. This is an 'old GUI builder' project, but it doesn't seem to be related to GUI builder in any case.
Here's how I get to the exception. On my main Form there is an
InfiniteContainer
which has many containers. Clicking a Button on one of these Containers brings the user to the next Form. In thebeforeShow
method of the second Form, I make a network call to get data related to that Form, usingNetworkManager.getInstance().addToQueueAndWait()
. This somehow ends up triggering theaddMoreComponents()
method of theInfiniteScrollAdapter
, which throws the exception because the list items it receives are all null.The first time I press the button, the second Form doesn't open, instead I get this:
The second time I press, it works fine.
UPDATE:
I tried running the function in
invokeAndBlock()
, but there was no change. If theInfiniteContainer
has no more items to add, then the exception doesn't occur (i.e. if I first scroll to the end of theInfiniteContainer
until it runs out of items to load).