question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PatternSyntaxException: Illegal character

See original GitHub issue

I want to set the requestTemplate header value to an array, but an error occurs

public class FeignConfig implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
            requestTemplate.header("roles", "{\"roles\":[\"default-role\"]}");
        }
    }
}
java.util.regex.PatternSyntaxException: Illegal character range near index 10
["default-role"]
          ^
	at java.util.regex.Pattern.error(Pattern.java:1957)
	at java.util.regex.Pattern.range(Pattern.java:2657)
	at java.util.regex.Pattern.clazz(Pattern.java:2564)
	at java.util.regex.Pattern.sequence(Pattern.java:2065)
	at java.util.regex.Pattern.expr(Pattern.java:1998)
	at java.util.regex.Pattern.compile(Pattern.java:1698)
	at java.util.regex.Pattern.<init>(Pattern.java:1351)
	at java.util.regex.Pattern.compile(Pattern.java:1028)
	at feign.template.Expression.lambda$new$0(Expression.java:35)
	at java.util.Optional.ifPresent(Optional.java:159)
	at feign.template.Expression.<init>(Expression.java:35)
	at feign.template.Expressions$SimpleExpression.<init>(Expressions.java:106)
	at feign.template.Expressions.create(Expressions.java:86)
	at feign.template.Template.parseFragment(Template.java:218)
	at feign.template.Template.parseTemplate(Template.java:202)
	at feign.template.Template.<init>(Template.java:61)
	at feign.template.HeaderTemplate.<init>(HeaderTemplate.java:110)
	at feign.template.HeaderTemplate.create(HeaderTemplate.java:72)
	at feign.RequestTemplate.lambda$appendHeader$3(RequestTemplate.java:758)
	at java.util.Map.compute(Map.java:1093)
	at feign.RequestTemplate.appendHeader(RequestTemplate.java:756)
	at feign.RequestTemplate.header(RequestTemplate.java:726)
	at feign.RequestTemplate.header(RequestTemplate.java:694)
	at com.commercial.consumer.config.FeignConfig.apply(FeignConfig.java:20)
......

How can I set it up so that it can work ?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mr-rajeshrathodcommented, Dec 2, 2021

I just discovered that this stopped working in v10.7.2 and later versions. So, It seems that this issue is happening because of the following commits.

https://github.com/OpenFeign/feign/pull/1138/commits https://github.com/OpenFeign/feign/pull/1139/commits/791f9e52d3cfcf71bf4e58dc121f2d44672374c5

0reactions
JKomoroskicommented, Oct 22, 2022

Here’s another issue this looks like another json header issue fixed in master at HEAD now. Related to the fixes that came in for https://github.com/OpenFeign/feign/issues/1464

I believe this can be closed @velo

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.util.regex.PatternSyntaxException: Illegal character range ...
PatternSyntaxException: Illegal character range near index occurs when an Illegal or inappropriate character range is used to match the regular expression.
Read more >
Illegal character range near index 17 - java - Stack Overflow
Inside a character class, - specifies a range: all the values between (inclusive) the ascii values of the two characters on the right...
Read more >
Understanding Why Regexp is Throwing Runtime Error
SystemOut O CSSFreeHandNameplateData: updatefreehandnameplatedata: java.util.regex.PatternSyntaxException: Illegal character range near ...
Read more >
Space or \\s at the end of Regular Expression fails.
PatternSyntaxException: Illegal character range near index 13 [ a-zA-Z0-9_- ]{1,40} ^ at java.util.regex.Pattern.error(Unknown Source)
Read more >
Is there list of Java regular expression errors, causes, solutions?
PatternSyntaxException's when calling java.util.regex.Pattern.Compile(String regex). ... Illegal character range near index 3
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found