Uploaded image for project: 'Kudu'
  1. Kudu
  2. KUDU-2188

kudu-client JAR built via JDK8 depends on Java 8 APIs



    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.5.0
    • 1.6.0, 1.5.1
    • java
    • None


      Even though we build our Java artifacts against JDK7 (by specifying source=1.7 and target=1.7) and we try to avoid introducing Java 8 only dependencies, there is one case where we've failed to do that. The issue is with ConcurrentHashMap.keySet(), which returns a Set in Java 7 and a ConcurrentHashMap.KeySetView in Java 8. The latter is a class that only exists in Java 8, but because it's a subtype of Set, it's legal to make that kind of API change.

      We use ConcurrentHashMap.keySet() in our Statistics.getTableSet() method, and as a result, if you build kudu-client using JDK8, you'll end up with a reference to a class that's only found in Java 8.

      I wrote a small test program to verify that this is indeed a problem:

      import org.apache.kudu.client.Statistics;
      class Main {
          public static void main(String[] args) {
              Statistics s = new Statistics();

      And, after first building the kudu-client JAR with JDK8, here is how I compiled and ran the test program:

      $ /opt/toolchain/openjdk-64bit- -cp kudu/java/kudu-client/target/kudu-client-1.6.0-SNAPSHOT.jar Main.java
      $ /opt/toolchain/openjdk-64bit- -cp kudu/java/kudu-client/target/kudu-client-1.6.0-SNAPSHOT.jar:. Main
      Exception in thread "main" java.lang.NoSuchMethodError: java.util.concurrent.ConcurrentHashMap.keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView;
          at org.apache.kudu.client.Statistics.getTabletSet(Statistics.java:144)
          at Main.main(Main.java:6)

      I don't know which of our release artifacts have this issue. This Statistics API is quite old so it presumably affects any that have been built by RMs using JDK8 rather than JDK7.




            adar Adar Dembo
            adar Adar Dembo
            0 Vote for this issue
            2 Start watching this issue