From 5c4b864a42604e16747f3d98a68b97618aac8e02 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Thu, 3 Sep 2015 13:01:17 -0400 Subject: [PATCH] Workaround pitfall in Java 8 target-type inference Target-type inference has been improved in Java 8. This leads to these lines now being interpreted as invoking String#valueOf(char[]) whereas they previously were interpreted as invoking String#valueOf(Object). This change leads to ClassCastExceptions during test execution. Simply casting the parameter to Object restores the old invocation. Closes #13315 --- .../org/elasticsearch/search/innerhits/InnerHitsIT.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java index b5d87feb48a..8b4ef4ed5e5 100644 --- a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java +++ b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.innerhits; -import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.index.IndexRequestBuilder; @@ -47,11 +46,8 @@ import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; import static org.hamcrest.Matchers.*; -import org.apache.lucene.util.LuceneTestCase.AwaitsFix; - /** */ -@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/13315") public class InnerHitsIT extends ESIntegTestCase { @Test @@ -737,7 +733,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getChild(), nullValue()); - assertThat(String.valueOf(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).fields().get("comments.message").getValue()), equalTo("fox eat quick")); + assertThat(String.valueOf((Object)response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).fields().get("comments.message").getValue()), equalTo("fox eat quick")); } @Test @@ -814,7 +810,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getChild(), nullValue()); - assertThat(String.valueOf(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).fields().get("comments.message").getValue()), equalTo("fox eat quick")); + assertThat(String.valueOf((Object)response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).fields().get("comments.message").getValue()), equalTo("fox eat quick")); } @Test