方法定义:
@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类定义:
public class CustomInputModel(){
private List<String> listOfString;
public List<String> getListOfString() {
return listOfString;
}
public void setListOfString(List<String> listOfString) {
this.listOfString = listOfString;
}
}
问题:
在runSomething方法中->如果使用了简单循环,则一切正常。但是,如果我使用forEach,则会收到以下错误。任何帮助表示赞赏。抱歉,如果我错过了明显的内容。
错误:
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)