openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1728225 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultLoaderService.java
Date Tue, 02 Feb 2016 21:52:06 GMT
Author: struberg
Date: Tue Feb  2 21:52:05 2016
New Revision: 1728225

URL: http://svn.apache.org/viewvc?rev=1728225&view=rev
Log:
OWB-1113 add error handling for serviceloading

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultLoaderService.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultLoaderService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultLoaderService.java?rev=1728225&r1=1728224&r2=1728225&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultLoaderService.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultLoaderService.java
Tue Feb  2 21:52:05 2016
@@ -18,6 +18,7 @@
  */
 package org.apache.webbeans.service;
 
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.LoaderService;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -25,6 +26,7 @@ import org.apache.webbeans.util.WebBeans
 import java.util.ArrayList;
 import java.util.List;
 import java.util.ServiceLoader;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
@@ -49,13 +51,24 @@ public class DefaultLoaderService implem
         if(JAVA_6_AVAILABLE)
         {
             List<T> result = new ArrayList<T>();
-            ServiceLoader<T> services = ServiceLoader.load(serviceType, classLoader);
+            try
+            {
+                ServiceLoader<T> services;
+                services = ServiceLoader.load(serviceType, classLoader);
 
-            for (T service : services)
+                for (T service : services)
+                {
+                    result.add(service);
+                }
+            }
+            catch (Error error)
             {
-                result.add(service);
+                // WTF! ServiceLoader is cool, but THAT is utter crap: it throws some Errors!
+                logger.log(Level.SEVERE, "Problem while loading CDI Extensions", error);
+                throw new WebBeansConfigurationException("Problem while loading CDI Extensions",
error);
             }
 
+
             return result;
         }
 



Mime
View raw message