incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1045112 - /incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
Date Mon, 13 Dec 2010 13:31:42 GMT
Author: not
Date: Mon Dec 13 13:31:41 2010
New Revision: 1045112

URL: http://svn.apache.org/viewvc?rev=1045112&view=rev
Log:
ARIES-515 Update to rethrow exception caused when creating a Context, but swallowing ones
caused when creating an InitialContextFactoryBuilder

Modified:
    incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java

Modified: incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java?rev=1045112&r1=1045111&r2=1045112&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
(original)
+++ incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
Mon Dec 13 13:31:41 2010
@@ -134,7 +134,7 @@ public final class ContextHelper {
           if (contextFactoryClass == null) {
             return new DelegateContext(context, environment);
           } else {
-            throw new NoInitialContextException("We could not find an InitialContextFactory
to use");
+            throw new NoInitialContextException("We could not find a provider for the InitialContextFactory
" + contextFactoryClass);
           }
         }
     }
@@ -212,17 +212,21 @@ public final class ContextHelper {
             for (ServiceReference ref : refs) {                    
                 InitialContextFactoryBuilder builder = (InitialContextFactoryBuilder) context.getService(ref);
                 try {
-                    factory = builder.createInitialContextFactory(environment);
-                    if (factory != null) {
-                      provider = new ContextProvider(context, ref, factory.getInitialContext(environment));
-                      break;
-                    } else {
-                      context.ungetService(ref); // we didn't get something back, so this
was no good.
-                    }
-                } catch (NamingException e) {
-                    // TODO: log
-                    // ignore
-                    context.ungetService(ref);
+                  factory = builder.createInitialContextFactory(environment);
+                } catch (NamingException ne) {
+                  // TODO: log
+                  // ignore this, if the builder fails we want to move onto the next one
+                }
+                
+                if (factory != null) {
+                  try {
+                    provider = new ContextProvider(context, ref, factory.getInitialContext(environment));
+                  } finally {
+                    context.ungetService(ref); // we didn't get something back, so this was
no good.
+                  }
+                  break;
+                } else {
+                  context.ungetService(ref); // we didn't get something back, so this was
no good.
                 }
             }
         }



Mime
View raw message