Ted Dunning created FLINK-4793: ---------------------------------- Summary: Using a local method with :: notation in Java 8 causes index out of bounds Key: FLINK-4793 URL: https://issues.apache.org/jira/browse/FLINK-4793 Project: Flink Issue Type: Bug Reporter: Ted Dunning
I tried to use the toString method on an object as a map function: {code} .<String>map(Trade::toString) {code} This caused an index out of bounds error: {code} java.lang.ArrayIndexOutOfBoundsException: -1 at org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:351) at org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:305) at org.apache.flink.api.java.typeutils.TypeExtractor.getMapReturnTypes(TypeExtractor.java:120) at org.apache.flink.streaming.api.datastream.DataStream.map(DataStream.java:506) at com.mapr.aggregate.AggregateTest.testAggregateTrades(AggregateTest.java:81) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) {code} On the other hand, if I use a public static method, like this: {code} .<Trade>map(Trade::fromString) {code} All is good. fromString and toString are defined like this: {code} public static Trade fromString(String s) throws IOException { return mapper.readValue(s, Trade.class); } @Override public String toString() { return String.format("{\"%s\", %d, %d, %.2f}", symbol, time, volume, price); } {code} This might be a viable restriction on what functions I can use, but there certainly should be a better error message, if so. -- This message was sent by Atlassian JIRA (v6.3.4#6332)