Weird error nullPointerException

I have a code in which i get 1/1000 times an error i cannot understand; as the code runs fine so many times i dont understand why this error is happening. And the error is not really clear to read:

java.lang.NullPointerException
at sun.java2d.pipe.GlyphListLoopPipe.drawGlyphList(GlyphListLoopPipe.java:50)
at sun.java2d.pipe.GlyphListPipe.drawGlyphVector(GlyphListPipe.java:137)
at sun.java2d.SunGraphics2D.drawGlyphVector(SunGraphics2D.java:3003)
at sun.font.ExtendedTextSourceLabel.handleDraw(ExtendedTextSourceLabel.java:193)
at sun.font.Decoration.drawTextAndDecorations(Decoration.java:122)
at sun.font.ExtendedTextSourceLabel.draw(ExtendedTextSourceLabel.java:197)
at java.awt.font.TextLine.draw(TextLine.java:776)
at java.awt.font.TextLayout.draw(TextLayout.java:2647)
at sun.java2d.SunGraphics2D.drawChars(SunGraphics2D.java:3031)
at processing.awt.PGraphicsJava2D.textLineImpl(PGraphicsJava2D.java:2061)
at processing.core.PGraphics.textLineAlignImpl(PGraphics.java:4981)
at processing.core.PGraphics.text(PGraphics.java:4654)
at processing.core.PGraphics.text(PGraphics.java:4605)
at processing.core.PApplet.text(PApplet.java:13031)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at processing.core.PApplet.method(PApplet.java:3730)
at processing.core.PApplet$2.run(PApplet.java:3768)

Does anybody has an idea for that???
thanks in advance

PS: this error happens at a moment when i am parsing Strings.

This error usually happens when you try to access something that does not exist (an object not initialized or a array index too big…)

Without your code, it hard to really help you thought…

Looking at the stack trace in the error, it seems to happen when it’s trying to draw some text.
From that, I guess the error happens with the text(...); function.

Does it point to the exact text(...); function that gives the error?
One thing you can do as a cheap workaround is to surround it with try-catch block:

try{
  text(...);
}catch(Exception e){
  println("Oh hey, that weird error happened again! Oh well.");
}

This, as a result, would end up not doing the text(...); function at that one time it makes an error, but at the end of the day your sketch is most likely running at 60FPS, so not drawing text one frame shouldn’t be critical.

@jb4x===
“GlyphListLoopPipe.drawGlyphList(GlyphListLoopPipe.java:50)”: what is precisely referred here?

Of course i know what is a null pointer e and that is not my question which is a) why the log does not refer to the code and to the class where the error was fired, as usually this kind of log does b) why this error was fired only one time, though the code was runned till now about 1000 times or more… As for putting code i cannot because it is too much long & complicated with 12 classes, a server, & 10 instances of the app running at same time; as i told i only know that the error is fired when parsing a little number (10 max) of short texts, more precisely short char sequences like “Chj12” or “CCH0” and extracting substrings for drawing them. These charseq are not randomly created but picked from an array and so are frequently parsed without any problem…
PS: i have left an instance of the app running since 12 hours: not any error!