Tuesday, August 30, 2011

Obscure JDBC Behavior

I am approaching the final stage of a truly majorly ugly project, and suddenly, for no apparent reason, it was failing, with very strange, apparently quite random errors, including such bloodcurdling SQL Exceptions as "System or internal error: NullPointerException" when trying to process rows coming back from Informix.  Worse, there seemed no rhyme or reason--and the errors appeared scattered across half a dozen classes under one very exceptional set of circumstances.

It turned out that this steaming pile of Java was forking--and this was the problem.  The process that refreshed the screen display was sharing its database session with the forked process that was producing a report in a popup window.   The report process apparently, at its completion, was closing the shared session.  Depending on how much data was in the report, how heavily loaded the database server was, moon phase, etc., it would inexplicably start throwing these weird exceptions, apparently because that shared session was no longer valid--and the other process, of course, did not know about this.

The solution was relatively simple: synchronize the processes by keeping track of when the report process started and completed, and preventing the screen refresh from moving forward until that report process was done.  Yes, this is the result of gerbils writing Java, and I get to clean up the mess.


Unknown said...

What I'd like to know is how much of that code you inherited was written by AnalyzeSoft...

Clayton said...

There are many guilty parties for this steaming pile; it is hard to identify how much of this flaming poo-pile is the work of AnalyzeSoft.