-
Notifications
You must be signed in to change notification settings - Fork 148
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
The resource method is called despite an IllegalArgumentException in ParamConverter::fromString #23266
Comments
Can you provide more detail on the issue. Like version of Eclipse GlassFish, error messages, how to reproduce the issue etc. |
GlassFish Version How to reproduce: import java.util.regex.Pattern;
...
@RequestScoped
public class Service{
...
@Path("pattern/{pattern}")
@GET
public String find(@PathParam("pattern") Pattern pattern){
...
return ...
}
} and use a @Provider
public class PatternParamConverterProvider implements ParamConverterProvider {
@Override
public <T> ParamConverter<T> getConverter(final Class<T> rawType, final Type genericType, final Annotation[] annotations) {
if (rawType.isAssignableFrom(Pattern.class))
return (ParamConverter<T>) new ParamConverter<Pattern>() {
@Override
public final Pattern fromString(final String regex) {
throw new IllegalArgumentException(...);
}
@Override
public final String toString(final Pattern pattern) {
return Optional.ofNullable(pattern).map(Pattern::pattern).orElse(null);
}
};
return null;
} Do a REST-call to --> |
This issue has been marked as inactive and old and will be closed in 7 days if there is no further activity. If you want the issue to remain open please add a comment |
@smillidge You asked for more details, they had been provided by @mwirth, but then nothing happened and the issue was auto-closed. So is this issue not reproducible or is it fixed? |
@mkarg no idea it was 3 years ago and the version number wasn't an Eclipse GlassFish version. |
So why not simply running the provided reproducer in latest GlassFish to see the bug in action? |
time - if it still an issue for you reopen or create another issue? |
Signed-off-by: David Matějček <[email protected]>
If it is so important for you, you could simply create a PR with the reproducer. I don't even know on which GlassFish version it did not work (2.33 does not exist), but on GlassFish 7.0.16-SNAPSHOT it works as expected. |
Environment Details
Problem Description
As per contract a ParamConverter has to throw an IllegalArgumentException if the supplied string cannot be parsed or is null.
If an implementation of ParamConverter throws an IllegalArgumentException in
ParamConverter::fromString
the resource method is called anyway (with the default value) but the process chain should be stopped.The text was updated successfully, but these errors were encountered: