RE: Is this a bug with oro?

"Balaji" <[email protected]> Tue, 31 Mar 2009 20:39:50 +0530
Newsgroups gmane.comp.jakarta.oro.user
Organization Lister
Message-ID <[email protected]>
------=_NextPart_000_0155_01C9B240.DE6C4B60
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_0156_01C9B240.DE6C4B60"


------=_NextPart_001_0156_01C9B240.DE6C4B60
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi Kevin,
 
Thanks a lot for your reply. Highly appreciate your help. Here are required
details.
 
The version is 2.0.8
 
The context is this.. trying to read a html file over http and parse values
of some hidden attributes in the html form.
 
Here is the code.. the exception occurs at the line marked below. Occurs
randomly and is not reproducable at will. 
The string passed to contains() is never null and is always checked for true
before calling getMatch(). Please check if Iam missing something.
 
******************class that contains the code that throws the
exception************
public class Parser
{
 
 private static Pattern  diTag;
 private static PatternMatcher primaryMatcher = new Perl5Matcher() ;
 private static PatternCompiler compiler = new Perl5Compiler() ;
 
 public static void initialize(){
  .
  .
  .
 }
 public Parser( StringBuffer input)
 {
  this.input = input ;
 }
 public Vector parse()
 {
  Vector returnValue=null;
  PatternMatcherInput patternMatcherInput = new
PatternMatcherInput(input.toString());
  int previous = 0 ;
  while(primaryMatcher.contains(patternMatcherInput,diTag))
  {
   MatchResult result = primaryMatcher.getMatch();  //exception is thrown
here....
   String dataString =
input.substring(previous,patternMatcherInput.getMatchBeginOffset());
   String tag = result.group(1);
   String inputS = result.group(2);
   try
   {
    returnValue=processDITag( tag.toUpperCase(),inputS ) ;
    previous = patternMatcherInput.getCurrentOffset() ;
   }
   catch(NotHandledException nh)
   {
    previous = patternMatcherInput.getMatchBeginOffset() ;
   }
  }
  return returnValue;
 }
 
 public Vector processDITag( String tag, String inputString ) throws
NotHandledException
 {
  .
  .
  .
 }
}
 
  
******************code that calls the method in the above
class*******************************
  diHTML = readInputFile(queryParametersBean.getSurveyName()); //reads the
data from a html file over http
  
       
  if(diHTML.length()==0)
  {
   LogWriter.info(CLASS_NAME,"loadPageEvent(HttpServletRequest req)","The
file name is not available" + sHtmlPath);   
   sFileName=ConfigBean.getProperty(sSerPathFileName); // replace with exact
file name
   sFileName=sFilePath + sFileName;
   queryParametersBean.setSurveyName(sFileName);
   diHTML = readInputFile(queryParametersBean.getSurveyName());
   LogWriter.info(CLASS_NAME,"loadPageEvent(HttpServletRequest req)","The
file name from config file" + sFileName);   
  }
  if(diHTML.length()==0) {
   LogWriter.info(CLASS_NAME,"loadPageEvent(HttpServletRequest req)","The
file name is not in akamai server");   
  }
  else {
   if(!( queryParametersBean.getEmail() != null &&
queryParametersBean.getEmail().length() != 0 &&
 
(ProcessorSupport.validateEmailAddress(queryParametersBean.getEmail())==fals
e) && diHTML.length() !=0))
         {  
    LogWriter.info(CLASS_NAME,"loadPageEvent(HttpServletRequest
req)","queryParametersBean track page load " +
queryParametersBean.getEmail());    
    System.out.println("inside load event");
    Parser myParser = new Parser(diHTML, queryParameters) ;
    Vector resultString=myParser.parse();
    Iterator itrelements=resultString.iterator();
    .
    .
    .
        }
    }
****************************************************************************
*********************************
 
Thanks,
Balaji Prabhakaran | Team Lead | Lister Technologies P Ltd
<http://www.listertechnologies.com/>  | AIM: BalajeeSP | direct:
1.352.553.4238 | office: +91.44.4225 2876 | cell: +91.98410.14404



DISCLAIMER:This email message and the files transmitted with it are for the
sole use of the intended recipient(s) and may contain confidential and
privileged information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient, please
contact the sender by reply email and destroy all copies of the original
message. 

 

  _____  

From: Kevin Markey [mailto:[email protected]] 
Sent: Tuesday, March 31, 2009 6:48 PM
To: ORO Users List; [email protected];
[email protected]
Subject: RE: Is this a bug with oro?



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),
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 = new Perl5Compiler();
private PatternMatcher m_matcher = new Perl5Matcher();
private Pattern m_commentRegex = m_compiler.compile ( "#" );

/** Extract comment from string. */
public String findComment ( String s )
{
   if ( s == null ) return null;
   if ( m_matcher.contains ( s, m_commentRegex ) )
   {
      MatchResult result = m_matcher.getMatch();
      String comment = 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?

Hello,

I occassionally get the below exception. The call to getMatch is causing a
NullPointerException.

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)

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.

I believe this is a bug. Can you guys, please confirm?
If so, is there a fix or a workaround for this bug?

Any help will be greatly appreciated.

Thanks,
Balaji Prabhakaran





------=_NextPart_001_0156_01C9B240.DE6C4B60
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>RE: Is this a bug with oro?</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.6000.16809" name=3DGENERATOR></HEAD>
<BODY>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009>Hi Kevin,</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009></SPAN></FONT>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009>Thanks a lot for your reply. Highly =
appreciate your=20
help. Here are required details.</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009></SPAN></FONT>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009>The version is 2.0.8</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009></SPAN></FONT>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009>The context is this.. trying to read a html =
file over=20
http and parse values of some hidden attributes in the html=20
form.</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009></SPAN></FONT>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009>Here is the code.. the exception occurs at =
the line=20
marked below. Occurs randomly and is not reproducable at will.=20
</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009>The string passed to contains() is never null =
and is=20
always checked for true before calling getMatch(). Please check if Iam =
missing=20
something.</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009></SPAN></FONT><FONT face=3DArial =
size=3D2><SPAN=20
class=3D819441114-31032009><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009></SPAN></FONT>&nbsp;</DIV></SPAN></FONT>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009>******************class that contains the =
code that=20
throws the exception************</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff =
size=3D2><SPAN=20
class=3D819441114-31032009>public class =
Parser<BR>{<BR>&nbsp;<BR>&nbsp;private=20
static Pattern&nbsp; diTag;<BR>&nbsp;private static PatternMatcher=20
primaryMatcher =3D new Perl5Matcher() ;<BR>&nbsp;private static =
PatternCompiler=20
compiler =3D new Perl5Compiler() ;<BR>&nbsp;<BR>&nbsp;public static void =

initialize(){<BR>&nbsp;&nbsp;.<BR>&nbsp;&nbsp;.<BR>&nbsp;&nbsp;.<BR>&nbsp=
;}<BR>&nbsp;public=20
Parser( StringBuffer input)<BR>&nbsp;{<BR>&nbsp;&nbsp;this.input =3D =
input=20
;<BR>&nbsp;}<BR>&nbsp;public Vector =
parse()<BR>&nbsp;{<BR>&nbsp;&nbsp;Vector=20
returnValue=3Dnull;<BR>&nbsp;&nbsp;PatternMatcherInput =
patternMatcherInput =3D new=20
PatternMatcherInput(input.toString());<BR>&nbsp;&nbsp;int previous =3D 0 =

;<BR>&nbsp;&nbsp;while(primaryMatcher.contains(patternMatcherInput,diTag)=
)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;MatchResult=20
result =3D primaryMatcher.getMatch();&nbsp; <FONT =
color=3D#ff0000>//exception is=20
thrown here....<BR></FONT>&nbsp;&nbsp;&nbsp;String dataString =3D=20
input.substring(previous,patternMatcherInput.getMatchBeginOffset());<BR>&=
nbsp;&nbsp;&nbsp;String=20
tag =3D result.group(1);<BR>&nbsp;&nbsp;&nbsp;String inputS =3D=20
result.group(2);<BR>&nbsp;&nbsp;&nbsp;try<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp=
;&nbsp;&nbsp;&nbsp;returnValue=3DprocessDITag(=20
tag.toUpperCase(),inputS ) ;<BR>&nbsp;&nbsp;&nbsp;&nbsp;previous =3D=20
patternMatcherInput.getCurrentOffset()=20
;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;catch(NotHandledException=20
nh)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;previous =3D=20
patternMatcherInput.getMatchBeginOffset()=20
;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;return=20
returnValue;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;public Vector processDITag( =
String=20
tag, String inputString ) throws=20
NotHandledException<BR>&nbsp;{<BR>&nbsp;&nbsp;.<BR>&nbsp;&nbsp;.<BR>&nbsp=
;&nbsp;.<BR>&nbsp;}<BR>}</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff =
size=3D2><SPAN=20
class=3D819441114-31032009></SPAN></FONT>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff =
size=3D2><SPAN=20
class=3D819441114-31032009><SPAN class=3D819441114-31032009><FONT=20
color=3D#000000>&nbsp;</FONT>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#000000 =
size=3D2><SPAN=20
class=3D819441114-31032009>******************code that calls the method =
in the=20
above class*******************************</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009>&nbsp;&nbsp;<FONT color=3D#0000ff>diHTML =3D=20
readInputFile(queryParametersBean.getSurveyName()); //reads the data =
from a html=20
file over=20
http<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nb=
sp;&nbsp;if(diHTML.length()=3D=3D0)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp=
;LogWriter.info(CLASS_NAME,"loadPageEvent(HttpServletRequest=20
req)","The file name is not available" +=20
sHtmlPath);&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;sFileName=3DConfigBean=
.getProperty(sSerPathFileName);=20
// replace with exact file =
name<BR>&nbsp;&nbsp;&nbsp;sFileName=3DsFilePath +=20
sFileName;<BR>&nbsp;&nbsp;&nbsp;queryParametersBean.setSurveyName(sFileNa=
me);<BR>&nbsp;&nbsp;&nbsp;diHTML=20
=3D=20
readInputFile(queryParametersBean.getSurveyName());<BR>&nbsp;&nbsp;&nbsp;=
LogWriter.info(CLASS_NAME,"loadPageEvent(HttpServletRequest=20
req)","The file name from config file" +=20
sFileName);&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;if(diHTML.l=
ength()=3D=3D0)=20
{<BR>&nbsp;&nbsp;&nbsp;LogWriter.info(CLASS_NAME,"loadPageEvent(HttpServl=
etRequest=20
req)","The file name is not in akamai=20
server");&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else=20
{<BR>&nbsp;&nbsp;&nbsp;if(!( queryParametersBean.getEmail() !=3D null =
&amp;&amp;=20
queryParametersBean.getEmail().length() !=3D 0 =
&amp;&amp;<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

(ProcessorSupport.validateEmailAddress(queryParametersBean.getEmail())=3D=
=3Dfalse)=20
&amp;&amp; diHTML.length() =
!=3D0))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;{&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;LogWriter.info(CLASS_NAME,"loadPageEvent(Http=
ServletRequest=20
req)","queryParametersBean track page load " +=20
queryParametersBean.getEmail());&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&=
nbsp;&nbsp;System.out.println("inside=20
load event");<BR>&nbsp;&nbsp;&nbsp;&nbsp;Parser myParser =3D new =
Parser(diHTML,=20
queryParameters) ;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Vector=20
resultString=3DmyParser.parse();<BR>&nbsp;&nbsp;&nbsp;&nbsp;Iterator=20
itrelements=3DresultString.iterator();</FONT></SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff =
size=3D2><SPAN=20
class=3D819441114-31032009>&nbsp;&nbsp;&nbsp; .</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff =
size=3D2><SPAN=20
class=3D819441114-31032009>&nbsp;&nbsp;&nbsp; .</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff =
size=3D2><SPAN=20
class=3D819441114-31032009>&nbsp;&nbsp;&nbsp; .</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff =
size=3D2><SPAN=20
class=3D819441114-31032009>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN=20
class=3D819441114-31032009><FONT color=3D#0000ff>&nbsp;&nbsp;&nbsp;=20
}<BR></FONT><FONT=20
color=3D#000000>*********************************************************=
****************************************************</FONT></DIV></SPAN><=
/FONT></SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D819441114-31032009><FONT face=3DArial=20
size=3D2>Thanks,</FONT></SPAN></DIV>
<DIV align=3Dleft><SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: rgb(111,114,99); FONT-FAMILY: =
Verdana"><STRONG>Balaji&nbsp;Prabhakaran</STRONG><FONT=20
color=3D#000000 size=3D3> </FONT></SPAN><FONT color=3Dblack =
size=3D1><SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: =
Verdana">|</SPAN></FONT><FONT=20
color=3Dblack><SPAN=20
style=3D"COLOR: black; FONT-FAMILY: =
Verdana">&nbsp;</SPAN></FONT><STRONG><B><FONT=20
color=3D#999999 size=3D1><SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: rgb(153,153,153); FONT-FAMILY: =
Verdana">Team Lead=20
</SPAN></FONT></B></STRONG><FONT color=3Dblack size=3D2><SPAN=20
style=3D"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">|=20
</SPAN></FONT><STRONG><B><FONT color=3D#fe560e size=3D1><SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: rgb(254,86,14); FONT-FAMILY: Verdana"><A =

href=3D"http://www.listertechnologies.com/">Lister Technologies P =
Ltd</A>=20
</SPAN></FONT></B></STRONG><FONT color=3Dblack><SPAN=20
style=3D"COLOR: black; FONT-FAMILY: Verdana"><FONT color=3Dblack =
size=3D2><SPAN=20
style=3D"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">|=20
</SPAN></FONT><B><FONT color=3D#999999 size=3D1><SPAN=20
style=3D"FONT-SIZE: 7.5pt; COLOR: rgb(153,153,153); FONT-FAMILY: =
Verdana">AIM:=20
BalajeeSP</SPAN></FONT></B></STRONG><FONT color=3Dblack size=3D1><SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: Verdana"> =
</SPAN></FONT><SPAN=20
style=3D"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">|</SPAN> =
<SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: rgb(153,153,153); FONT-FAMILY: =
Verdana"><STRONG>direct:=20
1.352.553.4238&nbsp;</STRONG><SPAN><SPAN=20
style=3D"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><SPAN=20
style=3D"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: =
Verdana">|&nbsp;<SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: rgb(153,153,153); FONT-FAMILY: =
Verdana"><STRONG>office:=20
+91.44.4225=20
2876</STRONG></SPAN></SPAN></SPAN></SPAN><STRONG>&nbsp;</STRONG><SPAN><SP=
AN=20
style=3D"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><SPAN=20
style=3D"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: =
Verdana">|</SPAN></SPAN></SPAN><STRONG>=20
cell: +91.98410.14404</STRONG></SPAN></SPAN></FONT></DIV>
<P class=3DMsoNormal><FONT face=3D"Times New Roman" color=3D#999999 =
size=3D3><SPAN=20
style=3D"FONT-SIZE: 12pt; COLOR: #999999"><IMG id=3D_x0000_i1025 =
height=3D48=20
src=3D"cid:819441114@31032009-233E" width=3D219 =
border=3D0><?XML:NAMESPACE PREFIX =3D O=20
/><O:P></O:P></SPAN></FONT></P>
<P class=3DMsoNormal=20
style=3D"mso-margin-top-alt: auto; mso-margin-bottom-alt: =
auto"><STRONG><B><FONT=20
face=3DTTFF4CE4C0t00 color=3D#333333 size=3D1><SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: #333333; FONT-FAMILY: =
TTFF4CE4C0t00">DISCLAIMER:</SPAN></FONT></B></STRONG><STRONG><B><FONT=20
face=3DTTFF4CAEB0t00 color=3D#333333 size=3D1><SPAN=20
style=3D"FONT-WEIGHT: normal; FONT-SIZE: 8pt; COLOR: #333333; =
FONT-FAMILY: TTFF4CAEB0t00">This</SPAN></FONT></B></STRONG><FONT=20
face=3DTTFF4CAEB0t00 color=3D#333333 size=3D1><SPAN=20
style=3D"FONT-SIZE: 8pt; COLOR: #333333; FONT-FAMILY: TTFF4CAEB0t00"> =
email=20
message and the files transmitted with it are for the sole use of the =
intended=20
recipient(s) and may contain confidential and privileged information. =
Any=20
unauthorized review, use, disclosure or distribution is prohibited. If =
you are=20
not the intended recipient, please contact the sender by reply email and =
destroy=20
all copies of the original message.</SPAN></FONT> </P>
<DIV>&nbsp;</DIV><BR>
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
<HR tabIndex=3D-1>
<FONT face=3DTahoma size=3D2><B>From:</B> Kevin Markey=20
[mailto:[email protected]] <BR><B>Sent:</B> Tuesday, March =
31, 2009=20
6:48 PM<BR><B>To:</B> ORO Users List; [email protected];=20
[email protected]<BR><B>Subject:</B> RE: Is this =
a bug=20
with oro?<BR></FONT><BR></DIV>
<DIV></DIV><!-- Converted from text/plain format -->
<P><FONT size=3D2>Some context and code in which this fails and data =
with which=20
this fails would help.<BR>Also the version you are using would=20
help.<BR><BR>However, inspecting 2.0.6 code (which is the most handy on =
the=20
machine I'm on -- I suspect other code is similar),<BR>there is only one =
place=20
in __setLastMatchResult() where you can get a NPE.&nbsp; =
__lastMatchResult is=20
non-null.&nbsp; OpCode is non-null.&nbsp; However, __originalInput MIGHT =
be=20
null.&nbsp; Hence you can get a NPE where the __originalInput.length is=20
tested.&nbsp; Check your code whether the string in contains() is null, =
and=20
always check if the result is true.<BR><BR>E.g.,<BR><BR>private =
PatternCompiler=20
m_compiler =3D new Perl5Compiler();<BR>private PatternMatcher m_matcher =
=3D new=20
Perl5Matcher();<BR>private Pattern m_commentRegex =3D m_compiler.compile =
( "#"=20
);<BR><BR>/** Extract comment from string. */<BR>public String =
findComment (=20
String s )<BR>{<BR>&nbsp;&nbsp; if ( s =3D=3D null ) return =
null;<BR>&nbsp;&nbsp; if=20
( m_matcher.contains ( s, m_commentRegex ) )<BR>&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MatchResult result =3D=20
m_matcher.getMatch();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String comment =
=3D=20
s.substring ( result.endOffset(0) );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
return=20
comment;<BR>&nbsp;&nbsp; }<BR>&nbsp;&nbsp; return=20
null;<BR>}<BR><BR>Enjoy.<BR>Kevin Markey<BR><BR>-----Original=20
Message-----<BR>From: Balaji [<A=20
href=3D"mailto:[email protected]">mailto:balaji.pr=
[email protected]</A>]<BR>Sent:=20
Tue 3/31/2009 6:22 AM<BR>To: [email protected]<BR>Subject: Is =
this a=20
bug with oro?<BR><BR>Hello,<BR><BR>I occassionally get the below =
exception. The=20
call to getMatch is causing a<BR>NullPointerException.<BR><BR>Caused by: =

java.lang.NullPointerException<BR>&nbsp;&nbsp;&nbsp; at=20
org.apache.oro.text.regex.Perl5Matcher.__setLastMatchResult(Unknown<BR>So=
urce)<BR>&nbsp;&nbsp;&nbsp;=20
at org.apache.oro.text.regex.Perl5Matcher.getMatch(Unknown =
Source)<BR><BR>Here=20
is what the API documentation says,<BR>A MatchResult instance containing =
the=20
pattern match found by the last call<BR>to any one of the matches() or=20
contains() methods. If no match was found by<BR>the last call, returns=20
null.<BR><BR>I believe this is a bug. Can you guys, please =
confirm?<BR>If so, is=20
there a fix or a workaround for this bug?<BR><BR>Any help will be =
greatly=20
appreciated.<BR><BR>Thanks,<BR>Balaji=20
Prabhakaran<BR><BR><BR></FONT></P></BODY></HTML>

------=_NextPart_001_0156_01C9B240.DE6C4B60--

------=_NextPart_000_0155_01C9B240.DE6C4B60--