After processing large amounts of data, I was merging multiple lucene indexes and got random null pointer exceptions. Surprisingly when I was trying to run the offending code alone, everything worked fine. Took me a while to figure that one out. Turned out that it was a bug in the JIT Compiler of Java 1.6.