You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by di...@apache.org on 2006/12/18 04:18:42 UTC

svn commit: r488106 - /geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java

Author: dims
Date: Sun Dec 17 19:18:42 2006
New Revision: 488106

URL: http://svn.apache.org/viewvc?view=rev&rev=488106
Log:
prevent NPE if the hashmap is empty

Modified:
    geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java

Modified: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java?view=diff&rev=488106&r1=488105&r2=488106
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java Sun Dec 17 19:18:42 2006
@@ -156,12 +156,13 @@
      * @param abstractName the abstract name of the gbean to unbind
      */
     protected synchronized void removeBinding(AbstractName abstractName) {
-        if (first(bindings).getKey().equals(abstractName)) {
+        Map.Entry entry = first(bindings);
+        if (entry != null && entry.getKey().equals(abstractName)) {
             Object oldValue = bindings.remove(abstractName);
-            Map.Entry newEntry = first(bindings);
-            if (newEntry != null) {
-                Object newAbstractName = newEntry.getValue();
-                Object newValue = newEntry.getValue();
+            entry = first(bindings);
+            if (entry != null) {
+                Object newAbstractName = entry.getValue();
+                Object newValue = entry.getValue();
                 try {
                     context.rebind(name, newValue);
                 } catch (NamingException e) {



Re: svn commit: r488106 - /geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java

Posted by anita kulshreshtha <a_...@yahoo.com>.
   It would be nice if this was included in 2.0-M1. It will allow clean
shutdown of the server without changing all the log levels from WARN to
ERROR.

Thanks
Anita

--- dims@apache.org wrote:

> Author: dims
> Date: Sun Dec 17 19:18:42 2006
> New Revision: 488106
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=488106
> Log:
> prevent NPE if the hashmap is empty
> 
> Modified:
>    
>
geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
> 
> Modified:
>
geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
> URL:
>
http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java?view=diff&rev=488106&r1=488105&r2=488106
>
==============================================================================
> ---
>
geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
> (original)
> +++
>
geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
> Sun Dec 17 19:18:42 2006
> @@ -156,12 +156,13 @@
>       * @param abstractName the abstract name of the gbean to unbind
>       */
>      protected synchronized void removeBinding(AbstractName
> abstractName) {
> -        if (first(bindings).getKey().equals(abstractName)) {
> +        Map.Entry entry = first(bindings);
> +        if (entry != null && entry.getKey().equals(abstractName)) {
>              Object oldValue = bindings.remove(abstractName);
> -            Map.Entry newEntry = first(bindings);
> -            if (newEntry != null) {
> -                Object newAbstractName = newEntry.getValue();
> -                Object newValue = newEntry.getValue();
> +            entry = first(bindings);
> +            if (entry != null) {
> +                Object newAbstractName = entry.getValue();
> +                Object newValue = entry.getValue();
>                  try {
>                      context.rebind(name, newValue);
>                  } catch (NamingException e) {
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com