You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/08/02 14:03:47 UTC

svn commit: r562086 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/beancontext/BeanContextServicesSupport.java test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java

Author: tellison
Date: Thu Aug  2 05:03:46 2007
New Revision: 562086

URL: http://svn.apache.org/viewvc?view=rev&rev=562086
Log:
Apply patch for HARMONY-4272 ([classlib][beans] BeanContextServicesSupport.releaseService() throws unexpected NPE)

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java?view=diff&rev=562086&r1=562085&r2=562086
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java Thu Aug  2 05:03:46 2007
@@ -837,11 +837,17 @@
     }
 
     /**
-     * Releases a service without checking the memebership of the child.
+     * Releases a service without checking the membership of the child.
      */
     private void releaseServiceWithoutCheck(BeanContextChild child,
             BCSSChild bcssChild, Object requestor, Object service,
             boolean callRevokedListener) {
+
+        if (bcssChild.serviceRecords == null
+                || bcssChild.serviceRecords.isEmpty()) {
+            return;
+        }
+
         synchronized (child) {
             // scan record
             for (Iterator iter = bcssChild.serviceRecords.iterator(); iter

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java?view=diff&rev=562086&r1=562085&r2=562086
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java Thu Aug  2 05:03:46 2007
@@ -1037,6 +1037,17 @@
         provider.records.assertEndOfRecords();
         assertNull(l.lastEvent);
     }
+    
+    /*
+     * regression test for HARMONY-4272
+     */
+    public void testReleaseService_WithNullServiceRecords()
+            throws TooManyListenersException {
+        MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
+        MockBeanContextChild child = new MockBeanContextChild();
+        support.add(child); 
+        support.releaseService(child, child, new Object()); 
+    }
 
     public void testReleaseService() throws TooManyListenersException,
             PropertyVetoException {