RE: Is this a bug with oro?
"Kevin Markey" <[email protected]> Tue, 31 Mar 2009 07:17:48 -0600
| Newsgroups | gmane.comp.jakarta.oro.user |
|---|---|
| Message-ID | <ACEAD257B132354FAB8210F67F619A9F01D6285E@scswhq.headquarters.silvercreeksystems.com> |
------_=_NextPart_001_01C9B203.166C68AA
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Some context and code in which this fails and data with which this fails =
would help.
Also the version you are using would help.
However, inspecting 2.0.6 code (which is the most handy on the machine =
I'm on -- I suspect other code is similar),=20
there is only one place in __setLastMatchResult() where you can get a =
NPE. __lastMatchResult is non-null. OpCode is non-null. However, =
__originalInput MIGHT be null. Hence you can get a NPE where the =
__originalInput.length is tested. Check your code whether the string in =
contains() is null, and always check if the result is true.
E.g.,
private PatternCompiler m_compiler =3D new Perl5Compiler();
private PatternMatcher m_matcher =3D new Perl5Matcher();
private Pattern m_commentRegex =3D m_compiler.compile ( "#" );
/** Extract comment from string. */
public String findComment ( String s )
{
if ( s =3D=3D null ) return null;
if ( m_matcher.contains ( s, m_commentRegex ) )
{
MatchResult result =3D m_matcher.getMatch();
String comment =3D s.substring ( result.endOffset(0) );
return comment;
}
return null;
}
Enjoy.
Kevin Markey
-----Original Message-----
From: Balaji [mailto:[email protected]]
Sent: Tue 3/31/2009 6:22 AM
To: [email protected]
Subject: Is this a bug with oro?
=20
Hello,
=20
I occassionally get the below exception. The call to getMatch is causing =
a
NullPointerException.
=20
Caused by: java.lang.NullPointerException
at =
org.apache.oro.text.regex.Perl5Matcher.__setLastMatchResult(Unknown
Source)
at org.apache.oro.text.regex.Perl5Matcher.getMatch(Unknown Source)
=20
Here is what the API documentation says,
A MatchResult instance containing the pattern match found by the last =
call
to any one of the matches() or contains() methods. If no match was found =
by
the last call, returns null.
=20
I believe this is a bug. Can you guys, please confirm?
If so, is there a fix or a workaround for this bug?
=20
Any help will be greatly appreciated.
=20
Thanks,
Balaji Prabhakaran
------_=_NextPart_001_01C9B203.166C68AA--