From dc2d406cf5a2f186fda53bf532fcbef4e481a84c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Fri, 11 Aug 2017 17:41:01 +0200 Subject: [PATCH] Make eclipse happy, type inference in lambdas is not working otherwise --- .../cluster/ClusterModuleTests.java | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java b/core/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java index 7ec086d4d68fe..81acd138d26fb 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java @@ -216,28 +216,35 @@ public Map> getInitialClusterStateCustomSu assertTrue(customSuppliers.containsKey(RestoreInProgress.TYPE)); assertTrue(customSuppliers.containsKey("foo")); - - IllegalStateException ise = expectThrows(IllegalStateException.class, - () -> ClusterModule.getClusterStateCustomSuppliers(Collections.singletonList(new ClusterPlugin() { - @Override - public Map> getInitialClusterStateCustomSupplier() { - return Collections.singletonMap(SnapshotsInProgress.TYPE, () -> null); - } - }))); - assertEquals(ise.getMessage(), "custom supplier key [snapshots] is registered more than once"); - - ise = expectThrows(IllegalStateException.class, - () -> ClusterModule.getClusterStateCustomSuppliers(Arrays.asList(new ClusterPlugin() { - @Override - public Map> getInitialClusterStateCustomSupplier() { - return Collections.singletonMap("foo", () -> null); - } - }, new ClusterPlugin() { - @Override - public Map> getInitialClusterStateCustomSupplier() { - return Collections.singletonMap("foo", () -> null); - } - }))); - assertEquals(ise.getMessage(), "custom supplier key [foo] is registered more than once"); + { + // Eclipse Neon 2 didn't compile the plugins definition inside the lambda expression, + // probably due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=511750, which is + // fixed in Eclipse Oxygon. Pulled out the plugins definition to make it work in older versions + List plugins = Collections.singletonList(new ClusterPlugin() { + @Override + public Map> getInitialClusterStateCustomSupplier() { + return Collections.singletonMap(SnapshotsInProgress.TYPE, () -> null); + } + }); + IllegalStateException ise = expectThrows(IllegalStateException.class, + () -> ClusterModule.getClusterStateCustomSuppliers(plugins)); + assertEquals(ise.getMessage(), "custom supplier key [snapshots] is registered more than once"); + } + { + List plugins = Arrays.asList(new ClusterPlugin() { + @Override + public Map> getInitialClusterStateCustomSupplier() { + return Collections.singletonMap("foo", () -> null); + } + }, new ClusterPlugin() { + @Override + public Map> getInitialClusterStateCustomSupplier() { + return Collections.singletonMap("foo", () -> null); + } + }); + IllegalStateException ise = expectThrows(IllegalStateException.class, + () -> ClusterModule.getClusterStateCustomSuppliers(plugins)); + assertEquals(ise.getMessage(), "custom supplier key [foo] is registered more than once"); + } } }