Jacques Belissent | 5 Apr 2004 23:54
Picon

Re: concurrent access to jregex.Matcher causes exception


Matthew A. Miller wrote:
> Now I fully understand and grasp where this was problematic.  I've made 
> the necessary changes to IxpParser to allocate the _StateRules at the 
> instance-level rather than the class-level.
> 
> CVS includes these changes, and http://jso.jabberstudio.org/dev/ and 
> http://jso.jabberstudio.org/files/dev/ is updated.  Everything seems to 
> work ok with some examples I've got, let me know if there are still issues.

No issue so far.  I think this one is solved, thanks.

> 
> 
> -  LW
> 
> Jacques Belissent wrote:
> 
>> Thanks for the quick response.
>>
>> Matthew A.Miller wrote:
>>
>>> Looking at the source, the Matcher field is *not* static.  Further
>>> analysis of the given stack trace indicates that somehow a null String
>>> was passed to Matcher.setTarget().  The IxpParser does everything it can
>>> to ensure a null String is not passed into the Rule.match() method.
>>>
>>> However, I've modified the BasicRule.match() to ensure that setTarget is
>>> not called with a null String.
>>
>>
>>
>> While the Matcher field is not static, it is only accessed by the 
>> containing Rule which itself is only obtained through _StateRules 
>> which is static.  So any use of a given rule type ends up using the 
>> same actual instance, and therefore the same Matcher instance.  Anyway 
>> this is how i read this code.
>>
>> I did revert to the official JSO version and was able to reproduce the 
>> original problem.
>>
>>>
>>> Have you made any changes to the IxpParser?  You may want to revert to
>>> the "official" CVS version.  The problem with matching only whitespace
>>> in TextRules has been fixed.
>>
>>
>>
>> Thanks for this.  Works for me.
>>
>> jacques
>>
>>
>>>
>>>
>>> -  LW On Fri, 2004-04-02 at 19:28, Jacques Belissent wrote:
>>>
>>>> Hi,
>>>>
>>>> _StateRules in IxpParser (and its contents) are static.  This means 
>>>> that multiple IxpParser instances within a program can access the 
>>>> same underlying jregex.Matcher with multiple threads.  And that may 
>>>> cause exceptions such as this one:
>>>>
>>>> Caused by: java.lang.NullPointerException
>>>>         at jregex.Matcher.search(jregex/Matcher.java:939)
>>>>         at jregex.Matcher.matchesPrefix(jregex/Matcher.java:376)
>>>>         at net.outer_planes.jso.ixp.BasicRule.match(BasicRule.java:57)
>>>>         at 
>>>> net.outer_planes.jso.ixp.EmptyTagRule.match(EmptyTagRule.java:44)
>>>>         at net.outer_planes.jso.ixp.IxpParser.parse(IxpParser.java:417)
>>>>         at 
>>>> net.outer_planes.jso.AbstractStream$Input.process(AbstractStream.java:145) 
>>>>
>>>>         at 
>>>> net.outer_planes.jso.AbstractStream.process(AbstractStream.java:1082)
>>>>         ... 12 more
>>>>
>>>> One way to alleviate the problem is to make _StateRules and its 
>>>> contents an instance variable and initialize it in the constructor.
>>>>
>>>> Jacques
>>>>
>>>> _______________________________________________
>>>> jso-devel mailing list
>>>> jso-devel <at> jabberstudio.org
>>>> https://jabberstudio.org/mailman/listinfo/jso-devel
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> jso-devel mailing list
>>> jso-devel <at> jabberstudio.org
>>> https://jabberstudio.org/mailman/listinfo/jso-devel
>>
>>
>>
>> _______________________________________________
>> jso-devel mailing list
>> jso-devel <at> jabberstudio.org
>> https://jabberstudio.org/mailman/listinfo/jso-devel
> 
> 
> _______________________________________________
> jso-devel mailing list
> jso-devel <at> jabberstudio.org
> https://jabberstudio.org/mailman/listinfo/jso-devel


Gmane