Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal argument exception thrown if the symbol has '$' symbol #132

Open
adilkaraoz opened this issue Aug 21, 2023 · 1 comment
Open

Illegal argument exception thrown if the symbol has '$' symbol #132

adilkaraoz opened this issue Aug 21, 2023 · 1 comment

Comments

@adilkaraoz
Copy link

adilkaraoz commented Aug 21, 2023

Describe the bug
A new symbol is added as 'JNJ$', that's why RestManager.java now throws IllegalArgumentException

To Reproduce
Steps to reproduce the behavior:

  1. Request for key stats (as an example, the others also have the same problem) with the symbol 'JNJ$'
  2. IllegalArgumentException will be thrown afterward from RestManager.java

Expected behavior
IllegalArgumentException won't be thrown and the response will be parsed successfully

Additional context
Caused by: java.lang.IllegalArgumentException: Illegal group reference: group index is missing
at java.base/java.util.regex.Matcher.appendExpandedReplacement(Unknown Source)
at java.base/java.util.regex.Matcher.appendReplacement(Unknown Source)
at java.base/java.util.regex.Matcher.replaceFirst(Unknown Source)
at java.base/java.lang.String.replaceFirst(Unknown Source)
at pl.zankowski.iextrading4j.client.rest.manager.RestManager.createPath(RestManager.java:94)
at pl.zankowski.iextrading4j.client.rest.manager.RestManager.createURL(RestManager.java:73)
at pl.zankowski.iextrading4j.client.rest.manager.RestManager.executeRequest(RestManager.java:30)
at pl.zankowski.iextrading4j.client.rest.AbstractRestEndpoint.execute(AbstractRestEndpoint.java:16)
at pl.zankowski.iextrading4j.client.rest.endpoint.GenericRestEndpoint.executeRequest(GenericRestEndpoint.java:14)

image
@adilkaraoz adilkaraoz changed the title Illegala argument exception thrown if the symbol has '$' symbol Illegal argument exception thrown if the symbol has '$' symbol Aug 21, 2023
@adilkaraoz
Copy link
Author

solution suggestion. You can send entry.getValue() to the following method and replace the path with the response.

public static String replaceAll(String source, String key, String value){ String[] split = source.split(Pattern.quote(key)); StringBuilder builder = new StringBuilder(); builder.append(split[0]); for (int i = 1; i < split.length; i++) { builder.append(value); builder.append(split[i]); } while (source.endsWith(key)) { builder.append(value); source = source.substring(0, source.length() - key.length()); } return builder.toString(); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant