Usage of whitespace in @Path regular expressions raises service deployment
errors
---------------------------------------------------------------------------------
Key: CXF-3168
URL: https://issues.apache.org/jira/browse/CXF-3168
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 2.3.0
Reporter: Glen Mazza
Priority: Minor
Fix For: 2.3.1
See: http://www.corneliadavis.com/blog/index.php/tag/rest-cxf-regex/
The following regular expression works fine (for an elephant maintenance system
at a zoo):
@Path("/{id:\\d+}")
public Person getElephantSubresource(@PathParam("id") int id);
However, placing spaces around the colon delimiter as follows:
@Path("/{id : \\d+}")
public Person getElephantSubresource(@PathParam("id") int id);
... causes these exceptions to occur at service deployment time:
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
Property 'serviceBeans' threw exception; nested exception is
java.util.regex.PatternSyntaxException: Illegal repetition near index 0
/{id : \d+}(/.*)?
^
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:22
....
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.util.regex.PatternSyntaxException: Illegal repetition near
index 0
/{id : \d+}(/.*)?
^
at java.util.regex.Pattern.error(Pattern.java:1713)
at java.util.regex.Pattern.closure(Pattern.java:2775)
at java.util.regex.Pattern.sequence(Pattern.java:1889)
at java.util.regex.Pattern.expr(Pattern.java:1752)
at java.util.regex.Pattern.compile(Pattern.java:1460)
at java.util.regex.Pattern.<init>(Pattern.java:1133)
at java.util.regex.Pattern.compile(Pattern.java:823)
at org.apache.cxf.jaxrs.model.URITemplate.<init>(URITemplate.java:89)
at
org.apache.cxf.jaxrs.model.URITemplate.createTemplate(URITemplate.java:302)
at
org.apache.cxf.jaxrs.model.URITemplate.createTemplate(URITemplate.java:289)
at
org.apache.cxf.jaxrs.utils.ResourceUtils.createOperationInfo(ResourceUtils.java:328)
at
org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:204)
The version with spaces is as shown on page 47 of Bill Burke's RESTFul Java
with JAX-RS book (O'Reilly).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.