[SPARK-19534][TESTS] Convert Java tests to use lambdas, Java 8 features#16964
[SPARK-19534][TESTS] Convert Java tests to use lambdas, Java 8 features#16964srowen wants to merge 3 commits intoapache:masterfrom
Conversation
|
+1, LGTM, too. Very tidy! |
| Assert.assertEquals(sketch1.totalCount(), 1000); | ||
| Assert.assertEquals(sketch1.depth(), 10); | ||
| Assert.assertEquals(sketch1.width(), 20); | ||
| Assert.assertEquals(1000, sketch1.totalCount()); |
There was a problem hiding this comment.
Here and in a few tests, I fixed the switched ordering on the asserts, while I was touching the code.
| TransportServerBootstrap auth = enableAes ? new AuthServerBootstrap(conf, keyHolder) | ||
| : new SaslServerBootstrap(conf, keyHolder); | ||
| this.server = ctx.createServer(Lists.newArrayList(auth, introspector)); | ||
| this.server = ctx.createServer(Arrays.asList(auth, introspector)); |
There was a problem hiding this comment.
I also think we can do away with things like Lists.newArrayList, which used to be a much more concise ways of making a list of things, but by Java 7, is just a non-standard version of the identical Arrays.asList
| @Test | ||
| public void testFileRegionEncryption() throws Exception { | ||
| final Map<String, String> testConf = ImmutableMap.of( | ||
| Map<String, String> testConf = ImmutableMap.of( |
There was a problem hiding this comment.
Anyone wondering about 'final' -- these are no longer needed because lambdas are OK with variables that are effectively final in the enclosing scope.
|
Test build #73011 has finished for PR 16964 at commit
|
|
Test build #73017 has finished for PR 16964 at commit
|
|
@srowen after update to master, in Eclipse IDE, there is an error in JavaConsumerStrategySuite.java line 52: line 49: Error is as follows: Is it related to updating Java 7 to 8? |
|
That code didn't change in the update for Java 8, and the error itself doesn't sound directly like a Java language level issue. (Although you see an anonymous function here, actually, this is an instance that could not change.) I don't see a compile error locally or on any Jenkins build either. Check your local env? clean build? |
| public void testLargeFrame() throws Exception { | ||
| // Frame length includes the frame size field, so need to add a few more bytes. | ||
| testInvalidFrame(Integer.MAX_VALUE + 9); | ||
| testInvalidFrame((long) Integer.MAX_VALUE + 9); |
There was a problem hiding this comment.
@vanzin I 'fixed' this test because as written it was actually testing negative input (this overflows) but that's tested above. However now this doesn't fail as expected. Is the test something I should remove actually?
There was a problem hiding this comment.
To unblock you, can you add @Ignore and file a bug to fix or remove this test?
There was a problem hiding this comment.
It looks like this call isn't invalid per se at the moment. There is a check later on in the code that compares a frame size to Integer.MAX_VALUE (but, as a long, so it works) and throws an exception, but that doesn't occur until later.
vanzin
left a comment
There was a problem hiding this comment.
I'm gonna miss all those anonymous classes and @Overrides...
| return new FileSegmentManagedBuffer(conf, file, 0, file.length()); | ||
| } | ||
| }); | ||
| when(sm.getChunk(anyLong(), anyInt())).thenAnswer(invocation -> new FileSegmentManagedBuffer(conf, file, 0, file.length())); |
There was a problem hiding this comment.
This line is now too long (although we don't have automatic java style checks.)
| import java.util.List; | ||
|
|
||
| import scala.Tuple2; | ||
| import org.apache.spark.mllib.linalg.DenseVector; |
|
Test build #73103 has finished for PR 16964 at commit
|
|
Merged to master |
## What changes were proposed in this pull request? Convert tests to use Java 8 lambdas, and modest related fixes to surrounding code. ## How was this patch tested? Jenkins tests Author: Sean Owen <sowen@cloudera.com> Closes #16964 from srowen/SPARK-19534.
## What changes were proposed in this pull request? Convert tests to use Java 8 lambdas, and modest related fixes to surrounding code. ## How was this patch tested? Jenkins tests Author: Sean Owen <sowen@cloudera.com> Closes apache#16964 from srowen/SPARK-19534.
|
@zzcclp@srowen I have the same error. In JavaConsumerStrategySuite.java,error is as follows: |
|
This isn't the right place to ask, and |
|
@srowen I want to know which IDE do you use? Eclipse or IDEA? |
|
@dahaian I think this is the issue of Eclipse, you can open 'JavaConsumerStrategySuite.java' file, remove the '.mapValues' and then retype '.mapValues' again, save file to recompile, it will resolve this issue. I resolved it by this way. |
|
@zzcclp I tried, failed. Any suggestions? |
What changes were proposed in this pull request?
Convert tests to use Java 8 lambdas, and modest related fixes to surrounding code.
How was this patch tested?
Jenkins tests