Load testing on a multi-CPU system uncovered another thread safety issue. I'm not sure why, because I'm unclear on the call flow, but the RegexpMatcher instance held by ResourceMatcherImpl can be called by two threads at once. This leads to predictable ArrayIndexOutOfBounds errors down in the ORO Perl5Matcher class, because that class has instance state that is being accessed by both threads, similar to the SimpleDateFormat issue in
I turned it into a ThreadLocal, which worked, but I think that loses some of the pattern caching performance benefits. Not sure what the best solution is, but a ThreadLocal is guaranteed to be safe.