You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/02 02:03:30 UTC

[GitHub] [kafka] hachikuji commented on a change in pull request #10010: MINOR: AbstractConfigTest.testClassConfigs should reset the class loa…

hachikuji commented on a change in pull request #10010:
URL: https://github.com/apache/kafka/pull/10010#discussion_r568270665



##########
File path: clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java
##########
@@ -276,52 +277,49 @@ public RestrictedClassLoader() {
         ClassLoader restrictedClassLoader = new RestrictedClassLoader();
         ClassLoader defaultClassLoader = AbstractConfig.class.getClassLoader();
 
-        // Test default classloading where all classes are visible to thread context classloader
-        Thread.currentThread().setContextClassLoader(defaultClassLoader);
-        ClassTestConfig testConfig = new ClassTestConfig();
-        testConfig.checkInstances(ClassTestConfig.DEFAULT_CLASS, ClassTestConfig.DEFAULT_CLASS);
-
-        // Test default classloading where default classes are not visible to thread context classloader
-        // Static classloading is used for default classes, so instance creation should succeed.
-        Thread.currentThread().setContextClassLoader(restrictedClassLoader);
-        testConfig = new ClassTestConfig();
-        testConfig.checkInstances(ClassTestConfig.DEFAULT_CLASS, ClassTestConfig.DEFAULT_CLASS);
-
-        // Test class overrides with names or classes where all classes are visible to thread context classloader
-        Thread.currentThread().setContextClassLoader(defaultClassLoader);
-        ClassTestConfig.testOverrides();
-
-        // Test class overrides with names or classes where all classes are visible to Kafka classloader, context classloader is null
-        Thread.currentThread().setContextClassLoader(null);
-        ClassTestConfig.testOverrides();
-
-        // Test class overrides where some classes are not visible to thread context classloader
-        Thread.currentThread().setContextClassLoader(restrictedClassLoader);
-        // Properties specified as classes should succeed
-        testConfig = new ClassTestConfig(ClassTestConfig.RESTRICTED_CLASS, Collections.singletonList(ClassTestConfig.RESTRICTED_CLASS));
-        testConfig.checkInstances(ClassTestConfig.RESTRICTED_CLASS, ClassTestConfig.RESTRICTED_CLASS);
-        testConfig = new ClassTestConfig(ClassTestConfig.RESTRICTED_CLASS, Arrays.asList(ClassTestConfig.VISIBLE_CLASS, ClassTestConfig.RESTRICTED_CLASS));
-        testConfig.checkInstances(ClassTestConfig.RESTRICTED_CLASS, ClassTestConfig.VISIBLE_CLASS, ClassTestConfig.RESTRICTED_CLASS);
-        // Properties specified as classNames should fail to load classes
+        ClassLoader origin = Thread.currentThread().getContextClassLoader();

Review comment:
       nit: maybe `originalClassLoader` to be consistent with other names?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org