You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a value that does not exist in an enum is sent in the request body of a request with Content-Type=text/plain, it should return 400 Bad request.
Actual Behaviour
When a value that does not exist in an enum is sent in the request body of a request with Content-Type=text/plain, it returns 500 Internal server error.
Steps To Reproduce
Create an enum. For example:
public enum Language {
EN_CA("en-CA"),
FR_CA("fr-CA");
@JsonValue
private final String locale;
public static Language fromLocale(String locale) {
return (Language) Arrays.stream(values()).filter((lang) -> {
return Objects.equals(lang.getLocale(), locale);
}).findFirst().orElse(null);
}
public String toString() {
return this.locale;
}
private Language(String locale) {
this.locale = locale;
}
public String getLocale() {
return this.locale;
}
}
Create a controller that receives the created enum as request body. For example:
@Controller
public class LanguageController {
@Put(value = "/language", processes = TEXT_PLAIN)
public HttpResponse<Void> putLanguage(@Body Language language) {
return HttpResponse.noContent();
}
}
Run the application and make a request to the endpoint with a non-existing enum value. For example:
This issue happens because the byteBuffer is released twice. First it is released in io.micronaut.http.body.TextPlainObjectBodyReader.read0, and then it is released again in io.micronaut.http.server.netty.binders.NettyBodyAnnotationBinder.read in the finally clause.
Expected Behavior
When a value that does not exist in an enum is sent in the request body of a request with Content-Type=text/plain, it should return 400 Bad request.
Actual Behaviour
When a value that does not exist in an enum is sent in the request body of a request with Content-Type=text/plain, it returns 500 Internal server error.
Steps To Reproduce
Notice that en-EN does not exist in the Language enum.
Environment Information
JDK version: 17
Example Application
No response
Version
4.7.6
The text was updated successfully, but these errors were encountered: