Closed
Description
Environment Details
- Helidon Version: 4.0.7
- Helidon SE
- JDK version: 21.0.2
- OS: MacOS
The implementation of Parameters.first(String)
has some issues: As it returns an optional value, it should never fail:
var content = req.content();
if(content.hasEntity()){
var params = content.as(Parameters.class);
var q = params.first("q");
if(q.isPresent()) {
...
}
}
... and here is the failure stack trace:
Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at io.helidon.common.parameters@4.0.7/io.helidon.common.parameters.ParametersMap.get(ParametersMap.java:70)
at io.helidon.common.parameters@4.0.7/io.helidon.common.parameters.ParametersMap.first(ParametersMap.java:101)
If you follow the stack trace, you will see the problem. My current workaround is to convert to a Map:
var content = req.content();
if(content.hasEntity()) {
var params = content.as(Parameters.class).toMap();
...
}
Metadata
Metadata
Assignees
Type
Projects
Status
Closed
Activity