Method definition:
@POST
@Path("/run")
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
public String runSomething(CustomInputModel customInputModel) {
// With simple loop
for (String machine : customInputModel.getListOfString()) {
.....
}
// With forEach
customInputModel.getListOfString().forEach((stringObj) -> {
.....
});
}
CustomInputModel class Definition:
public class CustomInputModel(){
private List<String> listOfString;
public List<String> getListOfString() {
return listOfString;
}
public void setListOfString(List<String> listOfString) {
this.listOfString = listOfString;
}
}
Problem:
In the runSomething method -> If the simple loop is used, everything works fine. However if I use forEach then I get the error below. Any help is appreciated. Apologies if I have missed something obvious.
Error:
SEVERE: Exception starting filter jersey
java.lang.ArrayIndexOutOfBoundsException: 25460
at org.objectweb.asm.ClassReader.readClass(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess(AnnotationScannerListener.java:133)
at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner$1.f(FileSchemeScanner.java:86)