Mylyn WikiText uses regular expressions to parse wiki markup. For Mylyn users, this means that your Bugzilla, JIRA and Trac bugs look good in the Eclipse UI. With the Galileo release of Eclipse, Mylyn WikiText added automatic stack trace detection.
Little did I know that the regular expression that I wrote would hang the Eclipse UI.
The intention was to format stack traces using a monospace font to improve layout:
Stack traces are detected by a regular expression. The regex that I created for this purpose worked well in testing, however for some stack traces would pin the CPU at near 100%, hanging the Eclipse UI. Here's what the regular expression looked like:
Actually, the full regular expression is a lot bigger:
The regex segment attempts to match a camel-case Java class name. What I didn't notice the first time around is that it contains nested greedy quantifiers. For some input can cause the CPU spiral of death... not good news.
To fix the offending regular expression is simple: just eliminate any nested quantifiers. My improved regular expression segment now looks like this:
Two things that I learned from this experience:
- Never write a regular expression that nests greedy quantifiers.
- Always ensure that testing involves sufficient diversity of input data.
- This In-App Purchase Has Aready Been Bought
- Mylyn WikiText on Maven Central
- Building a Cross-Platform Desktop Application with AngularJS and Java
- Firebase Mobile Analytics First Experiences
- Article Index
subscribe via RSS