You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "spark shen (JIRA)" <ji...@apache.org> on 2007/07/05 08:17:04 UTC

[jira] Created: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class

 [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
-----------------------------------------------------------------------------------------------

                 Key: HARMONY-4344
                 URL: https://issues.apache.org/jira/browse/HARMONY-4344
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: spark shen


The following test case will fail on Harmony but pass on RI:
        static int serviceRevoked = 0;

	static int serviceAvailable = 0;

	private static class MyListener implements BeanContextServicesListener {

		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
			serviceRevoked++;
		}

		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
			serviceAvailable++;
		}

	}

	private static class MySupport extends BeanContextServicesSupport {

		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
			serviceRevoked++;
		}
		
		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
			serviceAvailable++;
		}
	}

	private static class MyProvider implements BeanContextServiceProvider {

		public void releaseService(BeanContextServices s, Object requestor,
				Object service) {
		}

		public Iterator getCurrentServiceSelectors(BeanContextServices s,
				Class serviceClass) {

			return null;
		}

		public Object getService(BeanContextServices s, Object requestor,
				Class serviceClass, Object serviceSelector) {

			return null;

		}

	}
    public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
		BeanContextServicesSupport support = new BeanContextServicesSupport();

		support.add(new MySupport());
		support.addBeanContextServicesListener(new MyListener());
		Class c = Object.class;

		support.addService(c, new MyProvider());

		BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
				support, c);
	        support.serviceAvailable(availableEvent);

                assertEquals(2, serviceAvailable);
        
	}

Seems that serviceAvailable method does not judge whether the availableEvent.serviceClass has already be registered.
BeanContextServicesSupport.serviceRevoked method has similar defect. It can be revealed by the following test case:
public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
		BeanContextServicesSupport support = new BeanContextServicesSupport();

		support.add(new MySupport());
		support.addBeanContextServicesListener(new MyListener());
		Class c = Object.class;

		support.addService(c, new MyProvider());

		BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
				support, c, false);

		support.serviceRevoked(revokeEvent);
        assertEquals(0, serviceRevoked);
 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

spark shen closed HARMONY-4344.
-------------------------------


Verified at r556507. Thanks.

>  [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4344
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4344
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>            Assignee: Leo Li
>         Attachments: HY-4344.diff
>
>
> The following test case will fail on Harmony but pass on RI:
>         static int serviceRevoked = 0;
> 	static int serviceAvailable = 0;
> 	private static class MyListener implements BeanContextServicesListener {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MySupport extends BeanContextServicesSupport {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MyProvider implements BeanContextServiceProvider {
> 		public void releaseService(BeanContextServices s, Object requestor,
> 				Object service) {
> 		}
> 		public Iterator getCurrentServiceSelectors(BeanContextServices s,
> 				Class serviceClass) {
> 			return null;
> 		}
> 		public Object getService(BeanContextServices s, Object requestor,
> 				Class serviceClass, Object serviceSelector) {
> 			return null;
> 		}
> 	}
>     public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
> 				support, c);
> 	        support.serviceAvailable(availableEvent);
>                 assertEquals(2, serviceAvailable);
>         
> 	}
> Seems that serviceAvailable method does not judge whether the availableEvent.serviceClass has already be registered.
> BeanContextServicesSupport.serviceRevoked method has similar defect. It can be revealed by the following test case:
> public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
> 				support, c, false);
> 		support.serviceRevoked(revokeEvent);
>         assertEquals(0, serviceRevoked);
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

spark shen updated HARMONY-4344:
--------------------------------

    Attachment: HY-4344.diff

>  [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4344
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4344
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>         Attachments: HY-4344.diff
>
>
> The following test case will fail on Harmony but pass on RI:
>         static int serviceRevoked = 0;
> 	static int serviceAvailable = 0;
> 	private static class MyListener implements BeanContextServicesListener {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MySupport extends BeanContextServicesSupport {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MyProvider implements BeanContextServiceProvider {
> 		public void releaseService(BeanContextServices s, Object requestor,
> 				Object service) {
> 		}
> 		public Iterator getCurrentServiceSelectors(BeanContextServices s,
> 				Class serviceClass) {
> 			return null;
> 		}
> 		public Object getService(BeanContextServices s, Object requestor,
> 				Class serviceClass, Object serviceSelector) {
> 			return null;
> 		}
> 	}
>     public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
> 				support, c);
> 	        support.serviceAvailable(availableEvent);
>                 assertEquals(2, serviceAvailable);
>         
> 	}
> Seems that serviceAvailable method does not judge whether the availableEvent.serviceClass has already be registered.
> BeanContextServicesSupport.serviceRevoked method has similar defect. It can be revealed by the following test case:
> public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
> 				support, c, false);
> 		support.serviceRevoked(revokeEvent);
>         assertEquals(0, serviceRevoked);
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

spark shen updated HARMONY-4344:
--------------------------------

    Attachment:     (was: HY-4321.diff)

>  [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4344
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4344
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>
> The following test case will fail on Harmony but pass on RI:
>         static int serviceRevoked = 0;
> 	static int serviceAvailable = 0;
> 	private static class MyListener implements BeanContextServicesListener {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MySupport extends BeanContextServicesSupport {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MyProvider implements BeanContextServiceProvider {
> 		public void releaseService(BeanContextServices s, Object requestor,
> 				Object service) {
> 		}
> 		public Iterator getCurrentServiceSelectors(BeanContextServices s,
> 				Class serviceClass) {
> 			return null;
> 		}
> 		public Object getService(BeanContextServices s, Object requestor,
> 				Class serviceClass, Object serviceSelector) {
> 			return null;
> 		}
> 	}
>     public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
> 				support, c);
> 	        support.serviceAvailable(availableEvent);
>                 assertEquals(2, serviceAvailable);
>         
> 	}
> Seems that serviceAvailable method does not judge whether the availableEvent.serviceClass has already be registered.
> BeanContextServicesSupport.serviceRevoked method has similar defect. It can be revealed by the following test case:
> public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
> 				support, c, false);
> 		support.serviceRevoked(revokeEvent);
>         assertEquals(0, serviceRevoked);
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

spark shen updated HARMONY-4344:
--------------------------------

    Attachment: HY-4321.diff

Fix BeanContextServicesSupport.serviceAvailable & BeanContextServicesSupport.serviceRevoked  bugs. Would someone have a try?

>  [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4344
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4344
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>
> The following test case will fail on Harmony but pass on RI:
>         static int serviceRevoked = 0;
> 	static int serviceAvailable = 0;
> 	private static class MyListener implements BeanContextServicesListener {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MySupport extends BeanContextServicesSupport {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MyProvider implements BeanContextServiceProvider {
> 		public void releaseService(BeanContextServices s, Object requestor,
> 				Object service) {
> 		}
> 		public Iterator getCurrentServiceSelectors(BeanContextServices s,
> 				Class serviceClass) {
> 			return null;
> 		}
> 		public Object getService(BeanContextServices s, Object requestor,
> 				Class serviceClass, Object serviceSelector) {
> 			return null;
> 		}
> 	}
>     public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
> 				support, c);
> 	        support.serviceAvailable(availableEvent);
>                 assertEquals(2, serviceAvailable);
>         
> 	}
> Seems that serviceAvailable method does not judge whether the availableEvent.serviceClass has already be registered.
> BeanContextServicesSupport.serviceRevoked method has similar defect. It can be revealed by the following test case:
> public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
> 				support, c, false);
> 		support.serviceRevoked(revokeEvent);
>         assertEquals(0, serviceRevoked);
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class

Posted by "Leo Li (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leo Li reassigned HARMONY-4344:
-------------------------------

    Assignee: Leo Li

>  [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4344
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4344
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>            Assignee: Leo Li
>         Attachments: HY-4344.diff
>
>
> The following test case will fail on Harmony but pass on RI:
>         static int serviceRevoked = 0;
> 	static int serviceAvailable = 0;
> 	private static class MyListener implements BeanContextServicesListener {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MySupport extends BeanContextServicesSupport {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MyProvider implements BeanContextServiceProvider {
> 		public void releaseService(BeanContextServices s, Object requestor,
> 				Object service) {
> 		}
> 		public Iterator getCurrentServiceSelectors(BeanContextServices s,
> 				Class serviceClass) {
> 			return null;
> 		}
> 		public Object getService(BeanContextServices s, Object requestor,
> 				Class serviceClass, Object serviceSelector) {
> 			return null;
> 		}
> 	}
>     public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
> 				support, c);
> 	        support.serviceAvailable(availableEvent);
>                 assertEquals(2, serviceAvailable);
>         
> 	}
> Seems that serviceAvailable method does not judge whether the availableEvent.serviceClass has already be registered.
> BeanContextServicesSupport.serviceRevoked method has similar defect. It can be revealed by the following test case:
> public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
> 				support, c, false);
> 		support.serviceRevoked(revokeEvent);
>         assertEquals(0, serviceRevoked);
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class

Posted by "Leo Li (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leo Li resolved HARMONY-4344.
-----------------------------

    Resolution: Fixed

Hi, Spark
      
    Patch applied at r553714. Thank you for your improvement. Please verify whether the problem is resolved as you expected. 

Good luck! 
Leo. 

>  [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4344
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4344
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>            Assignee: Leo Li
>         Attachments: HY-4344.diff
>
>
> The following test case will fail on Harmony but pass on RI:
>         static int serviceRevoked = 0;
> 	static int serviceAvailable = 0;
> 	private static class MyListener implements BeanContextServicesListener {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MySupport extends BeanContextServicesSupport {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MyProvider implements BeanContextServiceProvider {
> 		public void releaseService(BeanContextServices s, Object requestor,
> 				Object service) {
> 		}
> 		public Iterator getCurrentServiceSelectors(BeanContextServices s,
> 				Class serviceClass) {
> 			return null;
> 		}
> 		public Object getService(BeanContextServices s, Object requestor,
> 				Class serviceClass, Object serviceSelector) {
> 			return null;
> 		}
> 	}
>     public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
> 				support, c);
> 	        support.serviceAvailable(availableEvent);
>                 assertEquals(2, serviceAvailable);
>         
> 	}
> Seems that serviceAvailable method does not judge whether the availableEvent.serviceClass has already be registered.
> BeanContextServicesSupport.serviceRevoked method has similar defect. It can be revealed by the following test case:
> public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
> 				support, c, false);
> 		support.serviceRevoked(revokeEvent);
>         assertEquals(0, serviceRevoked);
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.