Buggy code:
public class InMemoryDirectoryServiceFactory implements DirectoryServiceFactory { private static Logger LOG = LoggerFactory . getLogger ( InMemoryDirectoryServiceFactory . class ) ; private final DirectoryService directoryService ; private final PartitionFactory partitionFactory ; public InMemoryDirectoryServiceFactory ( ) { } public InMemoryDirectoryServiceFactory ( DirectoryService directoryService , PartitionFactory partitionFactory ) { } public void init ( String name ) throws Exception { <START_BUG> if ( ( ( directoryService ) != null ) && ( directoryService . isStarted ( ) ) ) { <END_BUG> return ; } directoryService . setInstanceId ( name ) ; InstanceLayout instanceLayout = new InstanceLayout ( ( ( ( System . getProperty ( "java.io.tmpdir" ) ) + "//server-work-" ) + name ) ) ; if ( instanceLayout . getInstanceDirectory ( ) . exists ( ) ) { try { FileUtils . deleteDirectory ( instanceLayout . getInstanceDirectory ( ) ) ; } catch ( IOException e ) { InMemoryDirectoryServiceFactory . LOG . warn ( "couldn't<seq2seq4repair_space>delete<seq2seq4repair_space>the<seq2seq4repair_space>instance<seq2seq4repair_space>directory<seq2seq4repair_space>before<seq2seq4repair_space>initializing<seq2seq4repair_space>the<seq2seq4repair_space>DirectoryService" , e ) ; } } directoryService . setInstanceLayout ( instanceLayout ) ; Configuration ehCacheConfig = new Configuration ( ) ; CacheConfiguration defaultCache = new CacheConfiguration ( "default" , 1 ) . eternal ( false ) . timeToIdleSeconds ( 30 ) . timeToLiveSeconds ( 30 ) . overflowToDisk ( false ) ; ehCacheConfig . addDefaultCache ( defaultCache ) ; CacheService cacheService = new CacheService ( new net . sf . ehcache . CacheManager ( ehCacheConfig ) ) ; directoryService . setCacheService ( cacheService ) ; SchemaLoader loader = new JarLdifSchemaLoader ( ) ; SchemaManager schemaManager = new org . apache . directory . api . ldap . schemamanager . impl . DefaultSchemaManager ( loader ) ; schemaManager . loadAllEnabled ( ) ; ComparatorRegistry comparatorRegistry = schemaManager . getComparatorRegistry ( ) ; for ( LdapComparator < ? > comparator : comparatorRegistry ) { if ( comparator instanceof NormalizingComparator ) { ( ( NormalizingComparator ) ( comparator ) ) . setOnServer ( ) ; } } directoryService . setSchemaManager ( schemaManager ) ; InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition ( schemaManager ) ; SchemaPartition schemaPartition = new SchemaPartition ( schemaManager ) ; schemaPartition . setWrappedPartition ( inMemorySchemaPartition ) ; directoryService . setSchemaPartition ( schemaPartition ) ; List < Throwable > errors = schemaManager . getErrors ( ) ; if ( ( errors . size ( ) ) != 0 ) { throw new Exception ( I18n . err ( ERR_317 , Exceptions . printErrors ( errors ) ) ) ; } Partition systemPartition = partitionFactory . createPartition ( directoryService . getSchemaManager ( ) , "system" , SYSTEM_DN , 500 , new File ( directoryService . getInstanceLayout ( ) . getPartitionsDirectory ( ) , "system" ) ) ; systemPartition . setSchemaManager ( directoryService . getSchemaManager ( ) ) ; partitionFactory . addIndex ( systemPartition , OBJECT_CLASS_AT , 100 ) ; directoryService . setSystemPartition ( systemPartition ) ; directoryService . startup ( ) ; } public DirectoryService getDirectoryService ( ) throws Exception { } public PartitionFactory getPartitionFactory ( ) throws Exception { } }

Fix:
if ( ( ( directoryService ) == null ) || ( directoryService . isStarted ( ) ) ) {