Uploaded image for project: 'Directory Client API'
  1. Directory Client API
  2. DIRAPI-317

Non thread-safe tests could lead to errors while running them

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0.AM1
    • 2.0.0.AM3
    • None

    Description

      From time to time, we might get a test failure, like teh one reported on Jenkins :

      java.lang.NullPointerException
      	at org.apache.directory.api.ldap.model.name.MultiThreadedTest.testNormalizeEquals(MultiThreadedTest.java:116)
      

      This is due to the fact that we are modifying a static variable (the irony :

      public class MultiThreadedTest
      {
          @Rule
          public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( 100, 1000 );
      
          private static Dn sharedDn;
          ...
          @BeforeClass
          public static void setup() throws Exception
          {
              schemaManager = new DefaultSchemaManager();
      
              referenceDn = new Dn( schemaManager, "dc=example,dc=com" );
              sharedDn = new Dn( schemaManager, "dc=example,dc=com" );
          ...
          }
          ...
          @Test
          public void testNormalizeHashCode() throws Exception
          {
              assertEquals( referenceAva.hashCode(), sharedAva.hashCode() );
      
              sharedRdn = new Rdn( schemaManager, sharedRdn );
              assertEquals( referenceRdn.hashCode(), sharedRdn.hashCode() );
      
              sharedDn = new Dn( schemaManager, sharedDn );  <------- This is *very* wrong
              assertEquals( referenceDn.hashCode(), sharedDn.hashCode() );
          }
          ...
      

      Many of the tests are updating the sharedDn - and some of the other static declarations -, which may lead to invalid tests, as all the tests are ran concurrently.

      This has to be fixed.

      Attachments

        Activity

          People

            Unassigned Unassigned
            elecharny Emmanuel L├ęcharny
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: