Buggy code:
public class WallsImporter { private static final Pattern BEGIN_LRUD_PATTERN = Pattern . compile ( "[<*]" ) ; private static final Pattern END_LRUD_PATTERN = Pattern . compile ( "[>*]" ) ; private static final Pattern LRUD_DELIMITER = Pattern . compile ( "\\s+|\\s*,\\s*" ) ; private static final Pattern PREFIX_PATTERN = Pattern . compile ( "pre(fix)?([123])?" ) ; Stack < WallsUnits > stack = new Stack < > ( ) ; WallsUnits units = new WallsUnits ( ) ; QObject < SurveyModel > outputModel ; Map < String , String > macros = new HashMap < > ( ) ; String globalComments = "" ; String localComments = "" ; final List < WallsImportMessage > statusMessages = new ArrayList < WallsImportMessage > ( ) ; I18n i18n ; Localizer localizer ; Path pathToSourceFile ; String line ; String preprocessedLine ; int lineNumber ; LineTokenizer lineTokenizer ; int blockCommentLevel ; WallsParser parser ; private int SHOT_CUSTOM_COLUMN_COUNT = 1 ; private int SHOT_LINE_COMMENT_COLUMN = 0 ; private final Map < String , Runnable > unitsOptionHandlers ; public WallsImporter ( I18n i18n ) { } private Map < String , Runnable > createUnitsOptionHandlers ( ) { } private void pullRequiredEquals ( ) { } private Unit < Length > pullRequiredDistanceUnit ( ) { } public QObject < SurveyModel > getOutputModel ( ) { } public void importSrvFile ( Path path , Subtask task ) throws IOException { } private void parseLine ( ) { } private void parseDirectiveLine ( ) { } private void parseUnits ( ) { } private void parseMacroDefinition ( ) { } private void parsePrefix ( int prefixIndex ) { } private Integer prefixIndex ( String directive ) { } public Shot parseVectorLine ( LineTokenizer lineTokenizer ) { } public void replaceMacroReferences ( StringBuilder line ) { int fromIndex = 0 ; while ( fromIndex < ( line . length ( ) ) ) { <START_BUG> int macroIndex = line . indexOf ( "$" ) ; <END_BUG> if ( macroIndex < 0 ) { return ; } if ( ( ( macroIndex + 1 ) < ( line . length ( ) ) ) && ( ( line . charAt ( ( macroIndex + 1 ) ) ) == '(' ) ) { int length = replaceMacroReference ( line , macroIndex ) ; fromIndex = macroIndex + length ; } else { fromIndex = macroIndex + 1 ; } } } private int replaceMacroReference ( StringBuilder line , int start ) { } private DaiShotVector coerceDaiShotVector ( Shot shot ) { } private NevShotVector coerceNevShotVector ( Shot shot ) { } private ParsedTextWithType < XSection > coerceXSectionParsedText ( Shot shot ) { } private LrudXSection coerceLrudXSection ( Shot shot ) { } private void pullRequiredWhitespace ( ) { } private WallsImportMessage createMessage ( Severity severity , String message , int lineNumber , int column ) { } private void logMessage ( Severity severity , String message , int line , int column ) { } private void throwMessage ( Severity severity , String message , int line , int column ) { } private class VectorElementParser implements VectorElementVisitor { private Shot shot ; private VectorElementParser ( Shot shot ) { } @ Override public void visitDistance ( ) { } @ Override public void visitAzimuth ( ) { } @ Override public void visitInclination ( ) { } @ Override public void visitEast ( ) { } @ Override public void visitNorth ( ) { } @ Override public void visitUp ( ) { } } private class LrudElementParser implements LrudElementVisitor { private Shot shot ; private LrudElementParser ( Shot shot ) { } private void handleLrudElement ( Consumer < UnitizedDouble < Length > > setter ) { } @ Override public void visitLeft ( ) { } @ Override public void visitRight ( ) { } @ Override public void visitUp ( ) { } @ Override public void visitDown ( ) { } } }

Fix:
int macroIndex = line . indexOf ( "$" , fromIndex ) ;