You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lecharny (JIRA)" <ji...@apache.org> on 2018/08/17 21:48:00 UTC

[jira] [Resolved] (DIRAPI-317) Non thread-safe tests could lead to errors while running them

     [ https://issues.apache.org/jira/browse/DIRAPI-317?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny resolved DIRAPI-317.
--------------------------------------
    Resolution: Fixed

Should be fixed with commit 284e8b7547aedc7950813bc9ebd86243c40dab09

> Non thread-safe tests could lead to errors while running them
> -------------------------------------------------------------
>
>                 Key: DIRAPI-317
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-317
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 2.0.0.AM1
>            Reporter: Emmanuel Lecharny
>            Priority: Major
>             Fix For: 2.0.0
>
>
> From time to time, we might get a test failure, like teh one reported on Jenkins :
> {noformat}
> java.lang.NullPointerException
> 	at org.apache.directory.api.ldap.model.name.MultiThreadedTest.testNormalizeEquals(MultiThreadedTest.java:116)
> {noformat}
> This is due to the fact that we are modifying a static variable (the irony ;-) :
> {code:java}
> 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() );
>     }
>     ...
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)