slinkydeveloper commented on a change in pull request #17897:
URL: https://github.com/apache/flink/pull/17897#discussion_r757612706



##########
File path: 
flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/FactoryUtil.java
##########
@@ -691,14 +689,27 @@ private static ValidationException 
enrichNoMatchingConnectorError(
     }
 
     private static List<Factory> discoverFactories(ClassLoader classLoader) {
-        try {
-            final List<Factory> result = new LinkedList<>();
-            ServiceLoader.load(Factory.class, 
classLoader).iterator().forEachRemaining(result::add);
-            return result;
-        } catch (ServiceConfigurationError e) {
-            LOG.error("Could not load service provider for factories.", e);
-            throw new TableException("Could not load service provider for 
factories.", e);
-        }
+        final List<Factory> result = new LinkedList<>();
+        ServiceLoaderUtil.load(Factory.class, classLoader)
+                .forEachRemaining(
+                        loadResult -> {
+                            if (loadResult.failed()) {
+                                if (loadResult.getError() instanceof 
NoClassDefFoundError) {

Review comment:
       The issue is that `NoClassDefFoundError` and the cause 
`ClassNotFoundException` both have no method to get the class name that failed 
to load. Reference:
   
   * 
https://docs.oracle.com/javase/8/docs/api/java/lang/ClassNotFoundException.html
   * 
https://docs.oracle.com/javase/8/docs/api/java/lang/NoClassDefFoundError.html
   
   I could extract the class name from the exception message, but i feel like 
it could be an unstable method, and might break with certain jdks... WDYT? Do 
you have some alternatives in mind? 




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to