kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject kudu git commit: KUDU-2188: restore Java 7 compatibility to artifacts built with JDK8
Date Tue, 10 Oct 2017 22:31:01 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 6523a773e -> afdeb9ea2


KUDU-2188: restore Java 7 compatibility to artifacts built with JDK8

This particular problem surfaced in an OpenJDK bug report [1] (more info
also available at [2]). To address it we can either:
- Set javac's "boot classpath" to JDK7's rt.jar when building with JDK8.
- Ensure that the ConcurrentHashMap is used as a Map when calling keySet().

Given that there's just one instance of this, the latter is way easier than
the former.

1. https://bugs.openjdk.java.net/browse/JDK-8151366
2. https://gist.github.com/AlainODea/1375759b8720a3f9f094

Change-Id: I27f3db32eaba759f2781a211673fe0aaabd3f83d
Reviewed-on: http://gerrit.cloudera.org:8080/8249
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <danburkert@apache.org>
Reviewed-by: Todd Lipcon <todd@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/afdeb9ea
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/afdeb9ea
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/afdeb9ea

Branch: refs/heads/master
Commit: afdeb9ea218216631ae325b3205c23adb1061037
Parents: 6523a77
Author: Adar Dembo <adar@cloudera.com>
Authored: Tue Oct 10 13:02:23 2017 -0700
Committer: Adar Dembo <adar@cloudera.com>
Committed: Tue Oct 10 22:30:41 2017 +0000

----------------------------------------------------------------------
 .../main/java/org/apache/kudu/client/Statistics.java   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/afdeb9ea/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java
index e47d3a6..421510e 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java
@@ -17,6 +17,7 @@
 
 package org.apache.kudu.client;
 
+import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLongArray;
@@ -141,7 +142,17 @@ public class Statistics {
    */
   public Set<String> getTabletSet() {
     Set<String> tablets = Sets.newHashSet();
-    for (String tablet : stsMap.keySet()) {
+    // This cast forces the compiler to invoke Map.keySet() rather than
+    // ConcurrentHashMap's override, which is critical because when this code
+    // is built with JDK8, ConcurrentHashMap.keySet() introduces a dependency
+    // on a Java 8 only API.
+    //
+    // Note: an alternative would be to always access stsMap as a Map, but that
+    // just moves the problem to the putIfAbsent() call in getTabletStatistics(),
+    // which is only a Map method in Java 8.
+    //
+    // See KUDU-2188 for details.
+    for (String tablet : ((Map<String, Statistics.TabletStatistics>) stsMap).keySet())
{
       tablets.add(tablet);
     }
     return tablets;


Mime
View raw message