From 1390a849e10568b40a5333059aebfe94f0239411 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Sat, 21 Jul 2018 10:07:08 +0200 Subject: [PATCH 1/2] [TEST] improve REST high-level client naming conventions check (#32244) Check the deprecated methods are effectively deprecated. Also compare the class rather than their names when checking argument types. --- .../client/RestHighLevelClientTests.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java index 5acc6f5552f..64a344790ca 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java @@ -724,8 +724,8 @@ public class RestHighLevelClientTests extends ESTestCase { assertEquals(0, method.getExceptionTypes().length); assertEquals(3, method.getParameterTypes().length); assertThat(method.getParameterTypes()[0].getSimpleName(), endsWith("Request")); - assertThat(method.getParameterTypes()[1].getName(), equalTo(RequestOptions.class.getName())); - assertThat(method.getParameterTypes()[2].getName(), equalTo(ActionListener.class.getName())); + assertThat(method.getParameterTypes()[1], equalTo(RequestOptions.class)); + assertThat(method.getParameterTypes()[2], equalTo(ActionListener.class)); } else { //A few methods return a boolean rather than a response object if (apiName.equals("ping") || apiName.contains("exist")) { @@ -738,18 +738,23 @@ public class RestHighLevelClientTests extends ESTestCase { //a few methods don't accept a request object as argument if (apiName.equals("ping") || apiName.equals("info")) { assertEquals(1, method.getParameterTypes().length); - assertThat(method.getParameterTypes()[0].getName(), equalTo(RequestOptions.class.getName())); + assertThat(method.getParameterTypes()[0], equalTo(RequestOptions.class)); } else { assertEquals(apiName, 2, method.getParameterTypes().length); assertThat(method.getParameterTypes()[0].getSimpleName(), endsWith("Request")); - assertThat(method.getParameterTypes()[1].getName(), equalTo(RequestOptions.class.getName())); + assertThat(method.getParameterTypes()[1], equalTo(RequestOptions.class)); } boolean remove = apiSpec.remove(apiName); - if (remove == false && deprecatedMethods.contains(apiName) == false) { - //TODO xpack api are currently ignored, we need to load xpack yaml spec too - if (apiName.startsWith("xpack.") == false) { - apiNotFound.add(apiName); + if (remove == false) { + if (deprecatedMethods.contains(apiName)) { + assertTrue("method [" + method.getName() + "], api [" + apiName + "] should be deprecated", + method.isAnnotationPresent(Deprecated.class)); + } else { + //TODO xpack api are currently ignored, we need to load xpack yaml spec too + if (apiName.startsWith("xpack.") == false) { + apiNotFound.add(apiName); + } } } } From 0a511cc76f770f910e512cbbe76ab27f966e1a26 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Sat, 21 Jul 2018 12:50:17 +0000 Subject: [PATCH 2/2] Improve message when JAVA_HOME not set (#32022) closes #31399 --- .../main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 9f54ae8b682..5da5912dabe 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -222,7 +222,11 @@ class BuildPlugin implements Plugin { // IntelliJ does not set JAVA_HOME, so we use the JDK that Gradle was run with return Jvm.current().javaHome } else { - throw new GradleException("JAVA_HOME must be set to build Elasticsearch") + throw new GradleException( + "JAVA_HOME must be set to build Elasticsearch. " + + "Note that if the variable was just set you might have to run `./gradlew --stop` for " + + "it to be picked up. See https://github.com/elastic/elasticsearch/issues/31399 details." + ) } } return javaHome