I have a client server application. Messages are being processed back and forth in the application.
I suspect that something doesn't have enough time to respond and/or it's not created in time.
This specific area of the code is processing a message where it sets data in the client. The way messages are processed is via commands. These commands are put into a thread pool executor. I get the below exception during runtime. However, when I debug and step into the execute method and then step over each line, I never hit the exception. This makes it really difficult to debug.
Any debugging suggestions would be highly appreciated as I am new to thread management( hopefully it has nothing to do with threads ).
Exception in thread "pool-1-thread-1" java.lang.NullPointerException
at Client.Commands.DisplayProjects.execute(DisplayProjects.java:47)
at Client.Commands.ClientCommand.run(ClientCommand.java:31)
at Client.Commands.ProcessData.execute(ProcessData.java:24)
at Client.Commands.ClientCommand.run(ClientCommand.java:31)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Below is the execute method:
@Override
public void execute(Client client) {
/* Create and display the form */
java.awt.EventQueue.invokeLater(() -> {
new SplashScreen(client).setVisible(true);
});
System.out.println("SplashScreen is null"+client.splashscreen==null);
client.splashscreen.setProjects(projects);
}
Below is the setProjects method:
public void setProjects(ArrayList<String> projects){
DefaultTableModel model = new DefaultTableModel();
int row = 0;model.setRowCount(0);
model.addColumn("Application", new Object[0]);
model.addColumn("Description", new Object[0]);
Iterator<String> iterator = projects.iterator();
while(iterator.hasNext()){
String name = iterator.next();
String[] projectRow = new String[2];
projectRow[0] = iterator.next();projectRow[1]="";
model.addRow(projectRow);
}
ProjectTable.setModel(model);
}