hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aajis...@apache.org
Subject [hadoop] branch trunk updated: YARN-9512. [JDK11] TestAuxServices#testCustomizedAuxServiceClassPath fails because of ClassCastException. (#1806)
Date Thu, 16 Jan 2020 03:22:08 GMT
This is an automated email from the ASF dual-hosted git repository.

aajisaka pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 14c2c3d  YARN-9512. [JDK11] TestAuxServices#testCustomizedAuxServiceClassPath fails
because of ClassCastException. (#1806)
14c2c3d is described below

commit 14c2c3d69d1864889f2d20ec79e2bf8e62e56a17
Author: Akira Ajisaka <aajisaka@apache.org>
AuthorDate: Thu Jan 16 12:21:50 2020 +0900

    YARN-9512. [JDK11] TestAuxServices#testCustomizedAuxServiceClassPath fails because of
ClassCastException. (#1806)
---
 .../containermanager/TestAuxServices.java          | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java
index da0b9cd..19bcee8 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java
@@ -61,10 +61,11 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.stream.Collectors;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -242,13 +243,20 @@ public class TestAuxServices {
     @Override
     public ByteBuffer getMetaData() {
       ClassLoader loader = Thread.currentThread().getContextClassLoader();
-      URL[] urls = ((URLClassLoader)loader).getURLs();
-      List<String> urlString = new ArrayList<String>();
-      for (URL url : urls) {
-        urlString.add(url.toString());
+      try {
+        URL[] urls = ((URLClassLoader) loader).getURLs();
+        String joinedString = Arrays.stream(urls)
+            .map(URL::toString)
+            .collect(Collectors.joining(","));
+        return ByteBuffer.wrap(joinedString.getBytes());
+      } catch (ClassCastException e) {
+        // In Java 11+, Thread.currentThread().getContextClassLoader()
+        // returns jdk.internal.loader.ClassLoaders$AppClassLoader
+        // by default and it cannot cast to URLClassLoader.
+        // This exception does not happen when the custom class loader is
+        // used from AuxiliaryServiceWithCustomClassLoader.
+        return super.meta;
       }
-      String joinedString = StringUtils.join(",", urlString);
-      return ByteBuffer.wrap(joinedString.getBytes());
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message