[
https://issues.apache.org/jira/browse/SLING-3817?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14096472#comment-14096472
]
Bob Paulin commented on SLING-3817:
-----------------------------------
It looks like the Java 8 Matcher class doesn't like it when the replacement
string contains a $ at the end so it throws an IllegalArgumentException.
from Matcher.java
{code}
} else if (nextChar == '$') {
// Skip past $
cursor++;
// Throw IAE if this "$" is the last character in replacement
if (cursor == replacement.length())
throw new IllegalArgumentException(
"Illegal group reference: group index is missing");
{code}
If you run with Java 7 and turn on the debug logging you can see that this
throws a StringIndexOutOfBoundsException that we're currently catching. So the
test currently throws an exception in both Java 7 and Java 8 so I don't think
there is any harm just catching and logging the IllegalArgumentException. See
attached patch. The test now passes on Java 8. Does it make sense to increase
the log level too so this is more visible?
> MockedResourceResolverImplTest.testMapping fails under Java 8 with Illegal
> group reference: group index is missing
> ------------------------------------------------------------------------------------------------------------------
>
> Key: SLING-3817
> URL: https://issues.apache.org/jira/browse/SLING-3817
> Project: Sling
> Issue Type: Bug
> Components: ResourceResolver
> Affects Versions: Resource Resolver 1.1.0
> Reporter: Robert Munteanu
> Fix For: Resource Resolver 1.1.2
>
> Attachments: SLING-3817.patch
>
>
> *Error Message*
> Illegal group reference: group index is missing
> *Stacktrace*
> {noformat}java.lang.IllegalArgumentException: Illegal group reference: group
> index is missing
> at java.util.regex.Matcher.appendReplacement(Matcher.java:819)
> at java.util.regex.Matcher.replaceFirst(Matcher.java:1004)
> at
> org.apache.sling.resourceresolver.impl.mapping.MapEntry.replace(MapEntry.java:276)
> at
> org.apache.sling.resourceresolver.impl.ResourceResolverImpl.map(ResourceResolverImpl.java:479)
> at
> org.apache.sling.resourceresolver.impl.ResourceResolverImpl.map(ResourceResolverImpl.java:369)
> at
> org.apache.sling.resourceresolver.impl.MockedResourceResolverImplTest.testMapping(MockedResourceResolverImplTest.java:489){noformat}
> *Standard Error*
> {noformat}946 [main] INFO
> org.apache.sling.resourceresolver.impl.mapping.MapEntry - createMapEntry:
> Configuration has external redirect to http://www.example.com/; not creating
> mapping for configuration in /etc/map/http/example.com.80
> 946 [main] INFO org.apache.sling.resourceresolver.impl.mapping.MapEntry -
> createMapEntry: Configuration has external redirect to
> http://www.example.com/; not creating mapping for configuration in
> /etc/map/http/any_example.com.80
> 947 [main] INFO org.apache.sling.resourceresolver.impl.mapping.MapEntry -
> createMapEntry: URL localhost\.\d*/cgi-bin/ contains a regular expression;
> not creating mapping for configuration in /etc/map/http/example.com.80/cgi-bin
> 947 [main] INFO org.apache.sling.resourceresolver.impl.mapping.MapEntry -
> createMapEntry: URL localhost\.\d*/gateway/ contains a regular expression;
> not creating mapping for configuration in /etc/map/http/example.com.80/gateway
> 947 [main] INFO org.apache.sling.resourceresolver.impl.mapping.MapEntry -
> createMapEntry: URL localhost\.\d*/stories/ contains a regular expression;
> not creating mapping for configuration in /etc/map/http/example.com.80/stories
> 947 [main] INFO org.apache.sling.resourceresolver.impl.mapping.MapEntry -
> createMapEntry: URL localhost\.\d* contains a regular expression; not
> creating mapping for configuration in /etc/map/http/localhost_any{noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)