REGEX - Long running thread - stuck at RE.java

"Zahir Mansuri" <[email protected]> Wed, 18 Aug 2010 11:10:40 -0400
Newsgroups gmane.comp.jakarta.regexp.user,gmane.comp.java.ofbiz.devel
Message-ID <[email protected]>
------_=_NextPart_001_01CB3EE7.861BA6C7
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi,

=20

We are facing high CPU usage in our application hosted on Tomcat. After
getting thread dumps, I see the following information. Seems like the
RE.java is getting processed continuously and due to this few threads in
Tomcat are stuck forever. This pushes the CPU usage above 90% and making
the application very unstable.=20

=20

Please advice.

=20

Below is the info from thread dump:

=20

TP-Processor5396" daemon prio=3D10 tid=3D0x022cff28 nid=3D0x1f91b =
runnable
[0x4dcfb000..0x4dcffc70]

            at org.apache.regexp.RE.matchNodes(RE.java:860)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchNodes(RE.java:1376)

            at org.apache.regexp.RE.matchAt(RE.java:1448)

            at org.apache.regexp.RE.match(RE.java:1498)

            at org.apache.regexp.RE.match(RE.java:1468)

            at org.apache.regexp.RE.match(RE.java:1561)

            at
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

            at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:290)

            at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:206)

            at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:233)

            at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:175)

            at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:128)

            at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:102)

            at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:109)

            at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:2
86)

            at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)

            at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)

            at
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)

            at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:
697)

            at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.
java:889)

            at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:690)

            at java.lang.Thread.run(Thread.java:595)

=20

=20

Here is the regex related code in our application :

=20

        try{

          RE r =3D new
RE("^[\\w\\-]+(\\.)?[\\w\\-]+@[\\w\\-\\.]+(\\.([a-z]){2,4})$");

          RE r1 =3D new RE("^\\w{5,65}$");

          match =3D r.match(userID);

          if(!match)

            match =3D r1.match(userID);

=20

        }catch(Exception ex){

            throw new BusinessException(ex);

        }

=20

Any thoughts????=20
=20
Do you really need to print this email? Help preserve our environment! =
Devez-vous vraiment imprimer ce courriel? Pensons a l'environnement!
__________________________________________________________
=20
Cogeco Cable operates under various legal entities and, except as =
specifically provided herein, this communication cannot be attributed to =
any given entity or be regarded as a statement of any given entity. The =
information in this message, including in all attachments, is =
confidential or privileged. In the event you have received this message =
in error and are not the intended recipient, you are hereby advised that =
any use, copying or reproduction of this document is strictly forbidden. =
Please notify immediately the sender of this error and destroy this =
message, including its attachments, as the case may be.
=20
Cogeco Cable exerce ses activites par l'entremise de differentes entites =
legales et, sauf si autrement indique dans la presente communication, =
celle-ci ne peut etre attribuee a l'une ou l'autre de ces entites en =
particulier ou consideree comme un enonce d'une de ces entites en =
particulier. L'information apparaissant dans ce message electronique et =
dans les documents qui y sont joints est de nature confidentielle ou =
privilegiee. Si ce message vous est parvenu par erreur et que vous n'en =
etes pas le destinataire vise, vous etes par les presentes avises que =
toute utilisation, copie ou distribution de ce message est strictement =
interdite. Vous etes donc prie d'en informer immediatement l'expediteur =
et de detruire ce message, ainsi que les documents qui y sont joints, le =
cas echeant.

__________________________________________________________

------_=_NextPart_001_01CB3EE7.861BA6C7--