You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2013/04/12 00:41:05 UTC

git commit: DELTASPIKE-339 intermediate fix

Updated Branches:
  refs/heads/master 98c6feee1 -> 055131e8e


DELTASPIKE-339 intermediate fix


Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/055131e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/055131e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/055131e8

Branch: refs/heads/master
Commit: 055131e8e94213ca7041ef7930881fd770fe7287
Parents: 98c6fee
Author: gpetracek <gp...@apache.org>
Authored: Fri Apr 12 00:39:44 2013 +0200
Committer: gpetracek <gp...@apache.org>
Committed: Fri Apr 12 00:39:44 2013 +0200

----------------------------------------------------------------------
 .../deltaspike/core/impl/util/JndiUtils.java       |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/055131e8/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/JndiUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/JndiUtils.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/JndiUtils.java
index 1fcecc1..85fa77b 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/JndiUtils.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/JndiUtils.java
@@ -32,6 +32,7 @@ import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 
 import org.apache.deltaspike.core.util.ClassUtils;
+import org.apache.deltaspike.core.util.ExceptionUtils;
 
 /**
  * This is the internal helper class for low level access to JNDI
@@ -76,7 +77,7 @@ public abstract class JndiUtils
         }
         catch (NamingException e)
         {
-            throw new IllegalStateException("Could not get " + name + " from JNDI", e);
+            throw ExceptionUtils.throwAsRuntimeException(e);
         }
     }
 
@@ -96,7 +97,7 @@ public abstract class JndiUtils
         }
         catch (NamingException e)
         {
-            throw new IllegalStateException("Could not get " + name + " from JNDI", e);
+            throw ExceptionUtils.throwAsRuntimeException(e);
         }
     }
 
@@ -168,15 +169,16 @@ public abstract class JndiUtils
      * Resolves an instances for the given naming context.
      *
      * @param name       context name
-     * @param targetType target type
+     * @param type       target type
      * @param <T>        type
      * @return the found instances, null otherwise
      */
     public static <T> Map<String, T> list(String name, Class<T> type)
     {
+        Map<String, T> result = new HashMap<String, T>();
+
         try
         {
-            Map<String, T> result = new HashMap<String, T>();
             NameParser nameParser = initialContext.getNameParser(name);
             NamingEnumeration<NameClassPair> enumeration = initialContext.list(name);
             while (enumeration.hasMoreElements())
@@ -185,11 +187,11 @@ public abstract class JndiUtils
                 Name bindingName = nameParser.parse(name).add(binding.getName());
                 result.put(binding.getName(), lookup(bindingName, type));
             }
-            return result;
         }
         catch (NamingException e)
         {
-            throw new IllegalStateException("Could not list " + name + " from JNDI", e);
+            LOG.log(Level.SEVERE, "InitialContext#list failed!", e);
         }
+        return result;
     }
 }