tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [08/14] incubator-tamaya git commit: Fix for NPE, when only one service instance is available in some cases.
Date Tue, 01 Mar 2016 16:47:54 GMT
Fix for NPE, when only one service instance is available in some cases.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/930eb1af
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/930eb1af
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/930eb1af

Branch: refs/heads/master
Commit: 930eb1af6591a4494023eaa568886f080039ef47
Parents: 69303be
Author: anatole <anatole@apache.org>
Authored: Tue Mar 1 17:43:46 2016 +0100
Committer: anatole <anatole@apache.org>
Committed: Tue Mar 1 17:43:46 2016 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/spi/ServiceContextManager.java  | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/930eb1af/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java b/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
index e325365..3073232 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
@@ -57,7 +57,9 @@ public final class ServiceContextManager {
         try {
             int highestOrdinal = 0;
             for (ServiceContext serviceContext : ServiceLoader.load(ServiceContext.class))
{
-                if (serviceContext.ordinal() > highestOrdinal) {
+                if(highestServiceContext==null){
+                    highestServiceContext = serviceContext;
+                }else if (serviceContext.ordinal() > highestOrdinal) {
                     highestServiceContext = serviceContext;
                     highestOrdinal = serviceContext.ordinal();
                 }
@@ -65,16 +67,6 @@ public final class ServiceContextManager {
         } catch (Exception e) {
             throw new ConfigException("ServiceContext not loadable", e);
         }
-//        if (highestServiceContext==null){
-//            String serviceContext = System.getProperty(ServiceContext.class.getName());
-//            if(serviceContext != null){
-//                try{
-//                    highestServiceContext = (ServiceContext)Class.forName(serviceContext).newInstance();
-//                } catch (Exception e) {
-//                    throw new ConfigException("Configured ServiceContext not loadable:
" + serviceContext, e);
-//                }
-//            }
-//        }
         if (highestServiceContext==null){
             throw new ConfigException("No ServiceContext found");
         }


Mime
View raw message