Return-Path: X-Original-To: apmail-lucene-dev-archive@www.apache.org Delivered-To: apmail-lucene-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 34571C6AB for ; Wed, 9 May 2012 00:40:18 +0000 (UTC) Received: (qmail 6781 invoked by uid 500); 9 May 2012 00:40:17 -0000 Delivered-To: apmail-lucene-dev-archive@lucene.apache.org Received: (qmail 6732 invoked by uid 500); 9 May 2012 00:40:16 -0000 Mailing-List: contact dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list dev@lucene.apache.org Received: (qmail 6723 invoked by uid 99); 9 May 2012 00:40:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 May 2012 00:40:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 May 2012 00:40:13 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id E532543BC8A for ; Wed, 9 May 2012 00:39:51 +0000 (UTC) Date: Wed, 9 May 2012 00:39:51 +0000 (UTC) From: "Eric Spishak (JIRA)" To: dev@lucene.apache.org Message-ID: <1485257917.41824.1336523991940.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Created] (SOLR-3446) PatternSyntaxException Crash from Unvalidated Regular Expression Usage MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Eric Spishak created SOLR-3446: ---------------------------------- Summary: PatternSyntaxException Crash from Unvalidated Regular Expression Usage Key: SOLR-3446 URL: https://issues.apache.org/jira/browse/SOLR-3446 Project: Solr Issue Type: Bug Affects Versions: 3.5 Reporter: Eric Spishak Attachments: SOLR-3446.patch Solr sometimes crashes with an unhelpful stack trace. If the PatternTokenizerFactory's "pattern" attribute is set to an invalid regular expression, a PatternSyntaxException is thrown and Solr fails to start. The PatternSyntaxException is not useful to users in diagnosing the error. I think it would be better to report a detailed error message. The attached patch makes this change. Note that the patch adds a small RegexUtil class with helper methods to determine whether a String is a valid regular expression and to generate error messages for invalid regular expressions. I feel that these helper methods are more readable than catching the PatternSyntaxException. Furthermore, they can be re-used if more bugs like this one are found. Steps to reproduce: # Patch in bug.patch #* Note that this sets PatternTokenizerFactory's pattern attribute to an invalid regular expression. # Run 'ant run-example' from the solr folder # See exception in console output on startup: {code} Apr 3, 2012 2:07:29 PM org.apache.solr.common.SolrException log SEVERE: java.util.regex.PatternSyntaxException: Unclosed group near index 1 ( ^ at java.util.regex.Pattern.error(Pattern.java:1713) at java.util.regex.Pattern.accept(Pattern.java:1571) at java.util.regex.Pattern.group0(Pattern.java:2533) at java.util.regex.Pattern.sequence(Pattern.java:1806) at java.util.regex.Pattern.expr(Pattern.java:1752) at java.util.regex.Pattern.compile(Pattern.java:1460) at java.util.regex.Pattern.(Pattern.java:1133) at java.util.regex.Pattern.compile(Pattern.java:847) at org.apache.solr.analysis.PatternTokenizerFactory.init(PatternTokenizerFactory.java:90) at org.apache.solr.schema.IndexSchema$5.init(IndexSchema.java:901) at org.apache.solr.schema.IndexSchema$5.init(IndexSchema.java:890) at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:148) at org.apache.solr.schema.IndexSchema.readAnalyzer(IndexSchema.java:910) at org.apache.solr.schema.IndexSchema.access$100(IndexSchema.java:62) at org.apache.solr.schema.IndexSchema$1.create(IndexSchema.java:450) at org.apache.solr.schema.IndexSchema$1.create(IndexSchema.java:435) at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:140) at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:480) at org.apache.solr.schema.IndexSchema.(IndexSchema.java:125) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:461) at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316) at org.apache.solr.core.CoreContainer.load(CoreContainer.java:207) at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:130) at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:94) at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.Server.doStart(Server.java:224) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.mortbay.start.Main.invokeMain(Main.java:194) at org.mortbay.start.Main.start(Main.java:534) at org.mortbay.start.Main.start(Main.java:441) at org.mortbay.start.Main.main(Main.java:119) {code} 4. Visit http://localhost:8983/solr/admin/ and see a similar message: {code} HTTP ERROR 500 Problem accessing /solr/admin/. Reason: Severe errors in solr configuration. Check your log files for more detailed information on what may be wrong. If you want solr to continue after configuration errors, change: false in solr.xml ... ------------------------------------------------------------- java.util.regex.PatternSyntaxException: Unclosed group near index 1 ( ^ at java.util.regex.Pattern.error(Pattern.java:1713) at java.util.regex.Pattern.accept(Pattern.java:1571) at java.util.regex.Pattern.group0(Pattern.java:2533) at java.util.regex.Pattern.sequence(Pattern.java:1806) at java.util.regex.Pattern.expr(Pattern.java:1752) at java.util.regex.Pattern.compile(Pattern.java:1460) at java.util.regex.Pattern.(Pattern.java:1133) at java.util.regex.Pattern.compile(Pattern.java:847) at org.apache.solr.analysis.PatternTokenizerFactory.init(PatternTokenizerFactory.java:90) at org.apache.solr.schema.IndexSchema$5.init(IndexSchema.java:901) at org.apache.solr.schema.IndexSchema$5.init(IndexSchema.java:890) at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:148) ... {code} After applying the patch, the following is printed to the console: {code} SEVERE: org.apache.solr.common.SolrException: invalid "pattern" regular expression for PatternTokenizerFactory: Unclosed group near index 1 ( ^ at org.apache.solr.analysis.PatternTokenizerFactory.init(PatternTokenizerFactory.java:90) at org.apache.solr.schema.IndexSchema$5.init(IndexSchema.java:901) at org.apache.solr.schema.IndexSchema$5.init(IndexSchema.java:890) at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:148) ... {code} And the following similar message is shown when visiting http://localhost:8983/solr/admin/ : {code} HTTP ERROR 500 Problem accessing /solr/admin/. Reason: Severe errors in solr configuration. Check your log files for more detailed information on what may be wrong. If you want solr to continue after configuration errors, change: false in solr.xml ... ------------------------------------------------------------- org.apache.solr.common.SolrException: invalid "pattern" regular expression for PatternTokenizerFactory: Unclosed group near index 1 ( ^ at org.apache.solr.analysis.PatternTokenizerFactory.init(PatternTokenizerFactory.java:90) at org.apache.solr.schema.IndexSchema$5.init(IndexSchema.java:901) at org.apache.solr.schema.IndexSchema$5.init(IndexSchema.java:890) at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:148) ... {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional commands, e-mail: dev-help@lucene.apache.org