Buggy code:
public class ManagerAppImpl implements ManagerApp { private final ManagerFactory factory ; @ Inject public ManagerAppImpl ( ManagerFactory factory ) { } @ Override public void processFile ( File file ) { } private boolean ParseFirstLineAndSetParameters ( File file ) { } private boolean canRequirementsBeMet ( Graph < ManagerAppTask > dependencies ) { } private synchronized void runNextTasks ( ) { } private boolean enoughResources ( ManagerAppTask task ) { } private static Graph < ManagerAppTask > parseToGraph ( File file ) { Graph < ManagerAppTask > tasksGraph = new lib . softwaredesign . graph . AdjacencyList ( ) ; Dictionary < String , ManagerAppTask > taskByName = new Hashtable < > ( ) ; Set < String > explicitTasksNames = new HashSet < > ( ) ; boolean firstLine = true ; try ( BufferedReader br = new BufferedReader ( new FileReader ( file ) ) ) { String line ; while ( ( line = br . readLine ( ) ) != null ) { if ( firstLine ) { firstLine = false ; continue ; } int explicitTaskNameEnd = ( line . contains ( "(" ) ) ? line . indexOf ( '(' ) : line . indexOf ( ':' ) ; String explicitTaskName = line . substring ( 0 , explicitTaskNameEnd ) ; explicitTasksNames . add ( explicitTaskName ) ; String [ ] propertiesStrings = line . substring ( ( ( line . indexOf ( ':' ) ) + 1 ) ) . split ( "," ) ; Integer [ ] properties = new Integer [ 4 ] ; for ( int i = 0 ; i < 4 ; ++ i ) { properties [ i ] = Integer . parseInt ( propertiesStrings [ i ] . trim ( ) ) ; } ManagerAppTask explicitTask = new ManagerAppTask ( ) ; explicitTask . setCpus ( properties [ 0 ] ) ; explicitTask . setMemory ( properties [ 1 ] ) ; explicitTask . setDisk ( properties [ 2 ] ) ; explicitTask . setPriority ( properties [ 3 ] ) ; explicitTask . setName ( explicitTaskName ) ; tasksGraph . addVertex ( explicitTask ) ; taskByName . put ( explicitTaskName , explicitTask ) ; } } catch ( Exception ignored ) { } try ( BufferedReader br = new BufferedReader ( new FileReader ( file ) ) ) { String line ; firstLine = true ; while ( ( line = br . readLine ( ) ) != null ) { if ( firstLine ) { firstLine = false ; continue ; } if ( ! ( line . contains ( "(" ) ) ) continue ; int explicitTaskNameEnd = ( line . contains ( "(" ) ) ? line . indexOf ( '(' ) : line . indexOf ( ':' ) ; String explicitTaskName = line . substring ( 0 , explicitTaskNameEnd ) ; <START_BUG> String tasksInParentheses = line . substring ( line . indexOf ( '(' ) , line . indexOf ( ')' ) ) ; <END_BUG> for ( String taskName : tasksInParentheses . split ( "," ) ) { taskName = taskName . trim ( ) ; if ( ! ( explicitTasksNames . contains ( taskName ) ) ) { ManagerAppTask implicitTask = new ManagerAppTask ( ) ; implicitTask . setCpus ( 0 ) ; implicitTask . setMemory ( 0 ) ; implicitTask . setDisk ( 0 ) ; implicitTask . setPriority ( 0 ) ; implicitTask . setName ( taskName ) ; tasksGraph . addVertex ( implicitTask ) ; tasksGraph . addEdge ( implicitTask , taskByName . get ( explicitTaskName ) ) ; } else { tasksGraph . addEdge ( taskByName . get ( taskName ) , taskByName . get ( explicitTaskName ) ) ; } } } } catch ( Exception ignored ) { } return tasksGraph ; } private ExternalManager external ; private int cpus ; private int disk ; private int memory ; private Toposorter < ManagerAppTask > sorter ; }

Fix:
String tasksInParentheses = line . substring ( ( ( line . indexOf ( '(' ) ) + 1 ) , line . indexOf ( ')' ) ) ;