Buggy code:
do { dependenciesAtDepth = new HashSet ( ) ; dInfo . dependenciesByLevel . add ( dependenciesAtDepth ) ; movesAtDepth = new HashSet ( ) ; dInfo . movesByLevel . add ( movesAtDepth ) ; for ( PolymorphicProposition fringeDependency : dInfo . dependenciesByLevel . get ( ( depth - 1 ) ) ) { pathSet . clear ( ) ; FactorAnalyser . DirectDependencyInfo ddInfo = getComponentDirectDependencies ( fringeDependency , pathSet ) ; dependenciesAtDepth . addAll ( ddInfo . dependencies ) ; movesAtDepth . addAll ( ddInfo . moves ) ; if ( ( dependenciesAtDepth . size ( ) ) >= ( mNumBaseProps ) ) { break ; } if ( ( System . currentTimeMillis ( ) ) > lAbortTime ) { FactorAnalyser . LOGGER . warn ( ( ( "Factorization<seq2seq4repair_space>analysis<seq2seq4repair_space>timed<seq2seq4repair_space>out<seq2seq4repair_space>after<seq2seq4repair_space>at<seq2seq4repair_space>least<seq2seq4repair_space>" + xiTimeout ) + "ms" ) ) ; xiGameCharacteristics . factoringFailedAfter ( xiTimeout ) ; return ; } } dependenciesAtDepth . removeAll ( dInfo . dependencies ) ; movesAtDepth . removeAll ( dInfo . moves ) ; dInfo . dependencies . addAll ( dependenciesAtDepth ) ; dInfo . moves . addAll ( movesAtDepth ) ; depth ++ ; } while ( ( ! ( dependenciesAtDepth . isEmpty ( ) ) ) && ( ( dInfo . dependencies . size ( ) ) < ( mNumBaseProps ) ) ) ; if ( ( dInfo . dependencies . size ( ) ) > ( ( ( mNumBaseProps ) * 2 ) // 3 ) ) { xiFactorInfo . mFactorsCalculated = true ; lFactors = null ; } } Map < PolymorphicComponent , FactorAnalyser . DependencyInfo > disjunctiveInputs = new HashMap < > ( ) ; pathSet . clear ( ) ; addDisjunctiveInputProps ( mStateMachine . getFullPropNet ( ) . getTerminalProposition ( ) , disjunctiveInputs , pathSet ) ; Set < PolymorphicComponent > controlOnlyInputs = new HashSet < > ( ) ; for ( PolymorphicProposition baseProp : mBasePropositions ) { pathSet . clear ( ) ; FactorAnalyser . DependencyInfo dInfo = ( ( FactorAnalyser . DependencyInfo ) ( getComponentDirectDependencies ( baseProp , pathSet ) ) ) ; if ( dInfo . moves . isEmpty ( ) ) { lControlSet . add ( baseProp ) ; } } xiFactorInfo . mControlSetCalculated = true ; xiFactorInfo . mControlSet = lControlSet ; FactorAnalyser . LOGGER . info ( ( "Control<seq2seq4repair_space>set:<seq2seq4repair_space>" + lControlSet ) ) ; if ( lFactors == null ) { return ; } for ( Map . Entry < PolymorphicComponent , FactorAnalyser . DependencyInfo > e : disjunctiveInputs . entrySet ( ) ) { e . getValue ( ) . dependencies . removeAll ( lControlSet ) ; if ( e . getValue ( ) . dependencies . isEmpty ( ) ) { controlOnlyInputs . add ( e . getKey ( ) ) ; } } for ( PolymorphicComponent c : controlOnlyInputs ) { disjunctiveInputs . remove ( c ) ; } Set < PolymorphicComponent > ignorableDisjuncts = new HashSet < > ( ) ; for ( Map . Entry < PolymorphicComponent , FactorAnalyser . DependencyInfo > e : disjunctiveInputs . entrySet ( ) ) { if ( ( e . getValue ( ) . dependencies . size ( ) ) > ( ( ( mNumBaseProps ) - ( lControlSet . size ( ) ) ) // 2 ) ) { ignorableDisjuncts . add ( e . getKey ( ) ) ; } } for ( PolymorphicComponent c : ignorableDisjuncts ) { disjunctiveInputs . remove ( c ) ; } while ( ! ( disjunctiveInputs . isEmpty ( ) ) ) { if ( ( System . currentTimeMillis ( ) ) > lAbortTime ) { FactorAnalyser . LOGGER . warn ( ( ( "Factorization<seq2seq4repair_space>analysis<seq2seq4repair_space>(post<seq2seq4repair_space>dependency<seq2seq4repair_space>phase)<seq2seq4repair_space>timed<seq2seq4repair_space>out<seq2seq4repair_space>after<seq2seq4repair_space>at<seq2seq4repair_space>least<seq2seq4repair_space>" + xiTimeout ) + "ms" ) ) ; xiGameCharacteristics . factoringFailedAfter ( xiTimeout ) ; return ; } Factor lNewFactor = new Factor ( ) ; lNewFactor . addAll ( disjunctiveInputs . values ( ) . iterator ( ) . next ( ) . dependencies ) ; lFactors . add ( lNewFactor ) ; for ( Factor lFactor : lFactors ) { boolean anyAdded ; do { anyAdded = false ; Set < PolymorphicComponent > inputsProcessed = new HashSet < > ( ) ; for ( Map . Entry < PolymorphicComponent , FactorAnalyser . DependencyInfo > e : disjunctiveInputs . entrySet ( ) ) { if ( lFactor . containsAny ( e . getValue ( ) . dependencies ) ) { lFactor . addAll ( e . getValue ( ) . dependencies ) ; lFactor . addAllMoves ( e . getValue ( ) . moves ) ; inputsProcessed . add ( e . getKey ( ) ) ; anyAdded = true ; } } for ( PolymorphicComponent p : inputsProcessed ) { disjunctiveInputs . remove ( p ) ; } } while ( anyAdded ) ; } } xiFactorInfo . mFactorsCalculated = true ; <START_BUG> if ( ( lFactors . size ( ) ) > 1 ) { <END_BUG> xiFactorInfo . mFactors = lFactors ; } return ; } private void addDisjunctiveInputProps ( PolymorphicComponent c , Map < PolymorphicComponent , FactorAnalyser . DependencyInfo > disjunctiveInputs , Set < PolymorphicComponent > pathSet ) { } private void recursiveAddDisjunctiveInputProps ( PolymorphicComponent c , Map < PolymorphicComponent , FactorAnalyser . DependencyInfo > disjunctiveInputs , Set < PolymorphicComponent > pathSet ) { } FactorAnalyser . DirectDependencyInfo buildImmediateBaseDependencies ( PolymorphicComponent xiC , FactorAnalyser . DirectDependencyInfo result , Set < PolymorphicComponent > pathSet ) { } private void recursiveBuildImmediateBaseDependencies ( PolymorphicComponent root , PolymorphicComponent c , FactorAnalyser . DirectDependencyInfo dInfo , Set < PolymorphicComponent > pathSet ) { } private FactorAnalyser . FactorInfo reloadAnalysis ( RuntimeGameCharacteristics xiCharacteristics ) { } private Set < PolymorphicProposition > reloadControlSet ( String xiSavedState ) { } private Set < Factor > reloadFactors ( String xiSavedState ) { } public static class FactorInfo { public boolean mControlSetCalculated = false ; public Set < PolymorphicProposition > mControlSet = new HashSet < > ( ) ; public boolean mFactorsCalculated = false ; public Set < Factor > mFactors ; } }

Fix:
if ( ( ( lFactors . size ( ) ) > 1 ) && ( ( lFactors . size ( ) ) <= ( FactorAnalyser . MAX_FACTORS ) ) ) {