Menu

#9 Static 'parse' call throws NPE

open
nobody
None
5
2000-11-17
2000-11-17
David Hanna
No

I discovered an interesting feature. The problem does not seem to be major deal but it was very interesting. It only occurs when I use Quick within a second product (Vitria http://www.vitria.com\).

The symptom: Every other call to parse an XML string throws a null pointer exception. I am using Quick within a Vitria translator. A translator is a OTS class that uses reflection to access custom traslation logic (mine) via a static method call. So, Quick is being used within this static method. Repeated calls to this translator (and hence the static method) fail every other time. Identical processing of the XML outside of Vitria works every time.

The cause: The context returned by QContextPool.allocate method is not null but any calls to that context cause a NPE. I think that the use of the stack of SoftReference objects is the real root of the problem. Somehow the 'pointer' returned is not null but object it points to is...

My solution: I changed the QContextPool.allocate method to return a new context every time and this solved the problem. I was hesitant to do so in the CVS version of Quick since this is a very context sensitive bug. Any ideas?

Discussion