shoal
  1. shoal
  2. SHOAL-86

Graceful handling of unexpected exceptions(NPEs) when GMS failed to join the group

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: 1.1
    • Component/s: GMS
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      86

      Description

      When GMS failed to join the group, GMS didn't throw a GMSException but
      unexpected exception like a NPE.

      There are two issues.

      1) GroupManagementService#join() API had better throw a GMSException instead of
      a NPE in an unexpected error.
      Here is the log.


      D:\shoal\gms>rungmsdemo.bat testServer testGroup CORE 30000 INFO
      D:\ibm_sdk60\bin
      [#|2009-03-
      31T10:32:01.677+0900|SEVERE|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=Applicatio
      nServer;C
      lassName=NetworkManager;MethodName=<init>;|Could not locate World PeerGroup
      Module Implementation.
      net.jxta.exception.PeerGroupException: Could not locate World PeerGroup Module
      Implementation.
      at
      net.jxta.peergroup.WorldPeerGroupFactory.getDefaultWorldPeerGroupClass
      (WorldPeerGroupFact
      ory.java:244)
      at net.jxta.peergroup.WorldPeerGroupFactory.<init>
      (WorldPeerGroupFactory.java:178)
      at com.sun.enterprise.jxtamgmt.NetworkManager.initWPGF
      (NetworkManager.java:623)
      at com.sun.enterprise.jxtamgmt.NetworkManager.<init>
      (NetworkManager.java:213)
      at com.sun.enterprise.jxtamgmt.ClusterManager.<init>
      (ClusterManager.java:133)
      at
      com.sun.enterprise.ee.cms.impl.jxta.GroupCommunicationProviderImpl.initializeGro
      upCommuni
      cationProvider(GroupCommunicationProviderImpl.java:138)
      at com.sun.enterprise.ee.cms.impl.jxta.GMSContext.join
      (GMSContext.java:123)
      at com.sun.enterprise.ee.cms.impl.common.GroupManagementServiceImpl.join
      (GroupManagementServ
      iceImpl.java:339)
      at com.sun.enterprise.ee.cms.tests.ApplicationServer.startGMS
      (ApplicationServer.java:156)
      at com.sun.enterprise.ee.cms.tests.ApplicationServer.run
      (ApplicationServer.java:107)
      at java.lang.Thread.run(Thread.java:735)

      #]

      Exception in thread "ApplicationServer" java.lang.NullPointerException
      at com.sun.enterprise.jxtamgmt.NetworkManager.getWorldPeerGroup
      (NetworkManager.java:725)
      at com.sun.enterprise.jxtamgmt.NetworkManager.startDomain
      (NetworkManager.java:696)
      at com.sun.enterprise.jxtamgmt.NetworkManager.start
      (NetworkManager.java:401)
      at com.sun.enterprise.jxtamgmt.ClusterManager.<init>
      (ClusterManager.java:136)
      at
      com.sun.enterprise.ee.cms.impl.jxta.GroupCommunicationProviderImpl.initializeGro
      upCommuni
      cationProvider(GroupCommunicationProviderImpl.java:138)
      at com.sun.enterprise.ee.cms.impl.jxta.GMSContext.join
      (GMSContext.java:123)
      at com.sun.enterprise.ee.cms.impl.common.GroupManagementServiceImpl.join
      (GroupManagementServ
      iceImpl.java:339)
      at com.sun.enterprise.ee.cms.tests.ApplicationServer.startGMS
      (ApplicationServer.java:156)
      at com.sun.enterprise.ee.cms.tests.ApplicationServer.run
      (ApplicationServer.java:107)
      at java.lang.Thread.run(Thread.java:735)


      When you try to run rungmsdemo.bat in IBM JDK6, you can see NPEs in
      GroupManagementService#join().

      2) At 1)'s case above, GMS's other APIs like the GroupHandle need graceful
      handling of this problem.

      I wrote some codes for this test(SimpleShoalAPITest.java).

      Test code is simple.


      try {
      gms.join();
      } catch( GMSException e ) {
      // It's OK.
      throw e;
      } catch( Throwable t ) {
      // unexpected error.
      List<String> exceptions = testSimpleAPIsWithUnexpectedException( gms );
      // print unexpected exceptions
      // ...
      }

      private List<String> testSimpleAPIsWithUnexpectedException(
      GroupManagementService gms ) {
      if( gms == null )
      return null; // It's OK.
      List<String> unexpectedExceptions = new Vector<String>();
      String dummyString = "";
      byte[] dummyBytes = new byte[0];

      GroupHandle gh = gms.getGroupHandle();
      if( gh == null )
      return null; // It's OK.
      // test APIs
      // ...
      }


      when GMS failed to join the group, but if GMS was not null and GroupHandle was
      not null, I checked all GroupHandle's APIs with dummy String and dummy bytes.

      Here is the full log


      D:\shoal\gms>java -classpath classes;lib\jxta.jar
      com.sun.enterprise.shoal.carryel.SimpleShoalAPITes
      t
      [#|2009-03-
      31T11:32:01.458+0900|INFO|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassNa
      me=Simple
      ShoalAPITest;MethodName=runSimpleSample;|Starting SimpleShoalAPITest....|#]

      [#|2009-03-
      31T11:32:02.052+0900|INFO|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassNa
      me=Simple
      ShoalAPITest;MethodName=initializeGMS;|Initializing Shoal for member: 67fbe786-
      ff24-4a1f-81d2-d795bc
      b9dd16 group:TestGroup|#]

      [#|2009-03-
      31T11:32:02.068+0900|FINE|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassNa
      me=GMSCon
      text;MethodName=<init>;|Initialized Group Communication System....|#]

      [#|2009-03-
      31T11:32:02.068+0900|INFO|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassNa
      me=Simple
      ShoalAPITest;MethodName=runSimpleSample;|Joining Group TestGroup|#]

      [#|2009-03-
      31T11:32:02.068+0900|FINE|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassNa
      me=GroupM
      anagementServiceImpl;MethodName=join;|Connecting to group......|#]

      [#|2009-03-
      31T11:32:02.130+0900|CONFIG|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Jxta
      Util;MethodName=configureJxtaLogging;|gms configureJxtaLogging: set jxta
      logging to default of SEVER
      E|#]

      [#|2009-03-
      31T11:32:02.208+0900|CONFIG|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Netw
      orkManager;MethodName=initWPGF;|initWPGF storeHome=.shoal\67fbe786-ff24-4a1f-
      81d2-d795bcb9dd16|#]

      [#|2009-03-
      31T11:32:02.208+0900|FINER|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassN
      ame=Netwo
      rkManager;MethodName=clearCache;|clearCache(.shoal\67fbe786-ff24-4a1f-81d2-
      d795bcb9dd16) on non-exsi
      stent directory|#]

      [#|2009-03-
      31T11:32:02.443+0900|SEVERE|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Netw
      orkManager;MethodName=<init>;|Could not locate World PeerGroup Module
      Implementation.
      net.jxta.exception.PeerGroupException: Could not locate World PeerGroup Module
      Implementation.
      at
      net.jxta.peergroup.WorldPeerGroupFactory.getDefaultWorldPeerGroupClass
      (WorldPeerGroupFact
      ory.java:244)
      at net.jxta.peergroup.WorldPeerGroupFactory.<init>
      (WorldPeerGroupFactory.java:178)
      at com.sun.enterprise.jxtamgmt.NetworkManager.initWPGF
      (NetworkManager.java:623)
      at com.sun.enterprise.jxtamgmt.NetworkManager.<init>
      (NetworkManager.java:213)
      at com.sun.enterprise.jxtamgmt.ClusterManager.<init>
      (ClusterManager.java:133)
      at
      com.sun.enterprise.ee.cms.impl.jxta.GroupCommunicationProviderImpl.initializeGro
      upCommuni
      cationProvider(GroupCommunicationProviderImpl.java:138)
      at com.sun.enterprise.ee.cms.impl.jxta.GMSContext.join
      (GMSContext.java:123)
      at com.sun.enterprise.ee.cms.impl.common.GroupManagementServiceImpl.join
      (GroupManagementServ
      iceImpl.java:339)
      at com.sun.enterprise.shoal.carryel.SimpleShoalAPITest.runSimpleSample
      (SimpleShoalAPITest.ja
      va:42)
      at com.sun.enterprise.shoal.carryel.SimpleShoalAPITest.main
      (SimpleShoalAPITest.java:25)

      #]

      [#|2009-03-
      31T11:32:02.443+0900|FINE|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassNa
      me=Networ
      kManager;MethodName=startDomain;|Rendezvous seed?:false|#]

      [#|2009-03-
      31T11:32:02.443+0900|CONFIG|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Netw
      orkManager;MethodName=startDomain;|set jxta Multicast Poolsize to 300|#]

      [#|2009-03-
      31T11:32:02.458+0900|CONFIG|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Netw
      orkManager;MethodName=startDomain;|node config adv = <?xml version="1.0"
      encoding="UTF-8"?>
      <!DOCTYPE jxta:CP>
      <jxta:CP xml:space="default" type="jxta:PlatformConfig"
      xmlns:jxta="http://jxta.org">
      <PID>
      urn:jxta:uuid-
      59616261646162614A7874615032503363A4CD95BF504B68B35687BA4517337A03
      </PID>
      <Name>
      67fbe786-ff24-4a1f-81d2-d795bcb9dd16
      </Name>
      <Desc>
      Created by Jxta Cluster Management NetworkManager
      </Desc>
      <Svc>
      <MCID>
      urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000A05
      </MCID>
      <Parm>
      <jxta:TransportAdvertisement
      xmlns:jxta="http://jxta.org" xml:space="preserv
      e" type="jxta:HTTPTransportAdvertisement">
      <Protocol>http</Protocol><ConfigMode>auto</ConfigMode><Port>9700</Port><ServerOf
      f/>
      </jxta:TransportAdvertisement>
      </Parm>
      </Svc>
      <Svc>
      <MCID>
      urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000905
      </MCID>
      <Parm>
      <jxta:TransportAdvertisement
      xmlns:jxta="http://jxta.org" xml:space="preserv
      e" type="jxta:TCPTransportAdvertisement">
      <Protocol>tcp</Protocol><ConfigMode>auto</ConfigMode><Port start="9701"
      end="9999">9701</Port><Multi
      castAddr>224.0.1.85</MulticastAddr><MulticastPort>1234</MulticastPort><Mcast_Poo
      l_Size>300</Mcast_Po
      ol_Size><MulticastSize>65536</MulticastSize>
      </jxta:TransportAdvertisement>
      </Parm>
      </Svc>
      <Svc>
      <MCID>
      urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000105
      </MCID>
      <Parm type="jxta:PeerGroupConfigAdv"
      xmlns:jxta="http://jxta.org" xml:space="preserv
      e">
      <PeerGroupID>urn:jxta:uuid-
      157B8869F02A4210BE61AA03D81ECC6659616261646162614E5047205032503302</PeerG
      roupID><PeerGroupName>TestGroup</PeerGroupName><PeerGroupDesc>TestGroup
      Infrastructure Group Name</P
      eerGroupDesc> </Parm>
      </Svc>
      <Svc>
      <MCID>
      urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000F05
      </MCID>
      <Parm type="jxta:RelayConfig" xmlns:jxta="http://jxta.org"
      xml:space="preserve" clie
      nt="true">
      <client/><server/> </Parm>
      </Svc>
      <Svc>
      <MCID>
      urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000605
      </MCID>
      <Parm type="jxta:RdvConfig" xmlns:jxta="http://jxta.org"
      xml:space="preserve" config
      ="client"/>
      </Svc>
      <Svc>
      <MCID>
      urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000505
      </MCID>
      <Parm type="jxta:PSEConfig" xmlns:jxta="http://jxta.org"
      xml:space="preserve"/>
      </Svc>
      </jxta:CP>

      #]

      [#|2009-03-
      31T11:32:02.505+0900|SEVERE|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Simp
      leShoalAPITest;MethodName=runSimpleSample;|Unexpected exception occured while
      joining group:
      java.lang.NullPointerException
      at com.sun.enterprise.jxtamgmt.NetworkManager.getWorldPeerGroup
      (NetworkManager.java:725)
      at com.sun.enterprise.jxtamgmt.NetworkManager.startDomain
      (NetworkManager.java:696)
      at com.sun.enterprise.jxtamgmt.NetworkManager.start
      (NetworkManager.java:401)
      at com.sun.enterprise.jxtamgmt.ClusterManager.<init>
      (ClusterManager.java:136)
      at
      com.sun.enterprise.ee.cms.impl.jxta.GroupCommunicationProviderImpl.initializeGro
      upCommuni
      cationProvider(GroupCommunicationProviderImpl.java:138)
      at com.sun.enterprise.ee.cms.impl.jxta.GMSContext.join
      (GMSContext.java:123)
      at com.sun.enterprise.ee.cms.impl.common.GroupManagementServiceImpl.join
      (GroupManagementServ
      iceImpl.java:339)
      at com.sun.enterprise.shoal.carryel.SimpleShoalAPITest.runSimpleSample
      (SimpleShoalAPITest.ja
      va:42)
      at com.sun.enterprise.shoal.carryel.SimpleShoalAPITest.main
      (SimpleShoalAPITest.java:25)

      #]

      [#|2009-03-
      31T11:32:02.505+0900|FINER|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassN
      ame=Distr
      ibutedStateCacheImpl;MethodName=addToCache;|Adding to DSC by local
      Member:67fbe786-ff24-4a1f-81d2-d7
      95bcb9dd16,Component:,key:,State:RECOVERY_IN_PROGRESS|1238466722505|#]

      [#|2009-03-
      31T11:32:02.505+0900|FINEST|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Dist
      ributedStateCacheImpl;MethodName=addToLocalCache;|Adding
      cKey=GMSMember:67fbe786-ff24-4a1f-81d2-d795
      bcb9dd16:Component::key: state=RECOVERY_IN_PROGRESS|1238466722505|#]

      [#|2009-03-
      31T11:32:02.505+0900|FINER|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassN
      ame=Distr
      ibutedStateCacheImpl;MethodName=printDSCContents;|67fbe786-ff24-4a1f-81d2-
      d795bcb9dd16:DSC now conta
      ins ---------
      209999666 key=GMSMember:67fbe786-ff24-4a1f-81d2-d795bcb9dd16:Component::key: :
      value=RECOVERY_IN_PRO
      GRESS|1238466722505

      #]

      [#|2009-03-
      31T11:32:02.521+0900|FINER|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassN
      ame=Group
      HandleImpl;MethodName=isFenced;|GMSMember:67fbe786-ff24-4a1f-81d2-
      d795bcb9dd16:Component::key: value
      :RECOVERY_IN_PROGRESS|1238466722505|#]

      [#|2009-03-
      31T11:32:02.521+0900|FINER|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;ClassN
      ame=Group
      HandleImpl;MethodName=isFenced;|Returning true for isFenced query|#]

      [#|2009-03-
      31T11:32:02.521+0900|SEVERE|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Simp
      leShoalAPITest;MethodName=runSimpleSample;|Unexpected exceptions occured:
      GroupHandle#sendMessage( String, byte[] ): java.lang.NullPointerException
      GroupHandle#sendMessage( String, String, byte[] ):
      java.lang.NullPointerException
      GroupHandle#sendMessage( String, String, byte[] ):
      java.lang.NullPointerException
      GroupHandle#raiseFence( String, String ): java.lang.NullPointerException
      GroupHandle#lowerFence( String, String ): java.lang.NullPointerException
      GroupHandle#getMemberState( String ): java.lang.NullPointerException
      GroupHandle#getMemberState( String, long, long ): java.lang.NullPointerException
      GroupHandle#getGroupLeader(): java.lang.NullPointerException
      GroupHandle#isGroupLeader(): java.lang.NullPointerException

      #]

      [#|2009-03-
      31T11:32:02.536+0900|SEVERE|Shoal|ShoalLogger|_ThreadID=0;_ThreadName=main;Class
      Name=Simp
      leShoalAPITest;MethodName=main;|Exception occured while testing some
      APIs:com.sun.enterprise.ee.cms.
      core.GMSException: java.lang.NullPointerException|#]


      As you can see, the following APIs(9 methods) are not safe.

      • GroupHandle#sendMessage( String, byte[] ): java.lang.NullPointerException
      • GroupHandle#sendMessage( String, String, byte[] ):
        java.lang.NullPointerException
      • GroupHandle#sendMessage( String, String, byte[] ):
        java.lang.NullPointerException
      • GroupHandle#raiseFence( String, String ): java.lang.NullPointerException
      • GroupHandle#lowerFence( String, String ): java.lang.NullPointerException
      • GroupHandle#getMemberState( String ): java.lang.NullPointerException
      • GroupHandle#getMemberState( String, long, long ):
        java.lang.NullPointerException
      • GroupHandle#getGroupLeader(): java.lang.NullPointerException
      • GroupHandle#isGroupLeader(): java.lang.NullPointerException

      Shoal should improve these NPEs.

      I attached my test code(SimpleShoalAPITest.java)

        Activity

        Hide
        carryel added a comment -

        Created an attachment (id=15)
        GroupHanlde API test code

        Show
        carryel added a comment - Created an attachment (id=15) GroupHanlde API test code
        Hide
        Joe Fialli added a comment -

        agree that GMS API methods should not be throwing NPE

        Show
        Joe Fialli added a comment - agree that GMS API methods should not be throwing NPE
        Hide
        Joe Fialli added a comment -

        Fixed.

        Regression test is com.sun.enterprise.ee.cms.tests.core.GroupHandleTest.java.
        Shell script runAPITests.sh.

        Verified that the originally checked in test filed with this bug also runs okay.
        Throw IllegalArgumentException when null is passed as a parameter and it is not
        allowed.

        Show
        Joe Fialli added a comment - Fixed. Regression test is com.sun.enterprise.ee.cms.tests.core.GroupHandleTest.java. Shell script runAPITests.sh. Verified that the originally checked in test filed with this bug also runs okay. Throw IllegalArgumentException when null is passed as a parameter and it is not allowed.

          People

          • Assignee:
            shreedhar_ganapathy
            Reporter:
            carryel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: