Well if you have been on my twitter stream, you would know that i had an issue with a NullPointerException getting thrown in a Java program.
The program was part of a quick and dirty proof-of-technology or PoT. The aim here was to have a program listen to the events from a broker and based on the events the program was required to get the details from the broker environment. The events that were of interest to me where create, update and delete.
The standalone program was structured like this:

The initialize() function returns a broker connection object and is used by the retrieveDetails() function to get the details from the broker.
The program worked perfectly for update and delete events. But when the create event was triggered the broker object was unable to get the details. It always returned null thus throwing the NullPointerException.
Well the solution to this was to create a new broker object within the retrieveDetails() function if the event is create. And it worked.
I have no idea why it didn’t work the way it was designed initially. It might be because the broker object was already created before the create event. But that could not be the reason as the broker object is only used to retrieve the details about the flow from the deployed broker and doesn’t really hold any information. It is similar to the database connection object which is used to query the details from the database.