I am maintaining a servlet written by other people about a year ago. While
processing the request, this servlet calls substitute() method of
org.apache.oro.text.regex.Util class. In a single-user mode the substitution
works just fine. In multi-user production mode I started noticing
NullPointerExceptions in the log. I organized stress-testing experiment, and
found out that NullPointerException and ArrayIndexOutOfBoundException are
thrown by Perl5M a t c h er class with the following stack traces:
 
1.
java.lang.NullPointerException:  
at org.apache.oro.text.regex.Perl5M a t c h er.__setLastMatchResult(Perl5M a
t c h er.java:243) 
at org.apache.oro.text.regex.Perl5M a t c h er.getMatch(Perl5M a t c h
er.java:1761) 
at org.apache.oro.text.regex.Util.substitute(Util.java:354) 
at myservlet.fun(myservlet.java:188)
 
2.
java.lang.ArrayIndexOutOfBoundsException 
at org.apache.oro.text.regex.Perl5M a t c h er.__setLastMatchResult(Perl5M a
t c h er.java:244) 
at org.apache.oro.text.regex.Perl5M a t c h er.getMatch(Perl5M a t c h
er.java:1761) 
at org.apache.oro.text.regex.Util.substitute(Util.java:354) 
at myservlet.fun(myservlet.java:188)
 
It looks like it is not safe to use Util.substitute() in a multithreaded
environment. I tried the following ("this" is a reference to myservlet):
synchronized(this){
Util.substitute(...)
}
... but I got the same 2 exceptions as a result.
 
Please, help me figure out how to use ORO in a thread-safe fashion.
Thanks!
Vasili Smaliak
 
 
 


Reply via email to