Buggy code:
public class CodeFormatter implements ICodeFormatter , ITerminalSymbols { public FormatterOptions options ; public static final int BLOCK = ITerminalSymbols . TokenNameLBRACE ; public static final int NONINDENT_BLOCK = - 100 ; StringBuffer formattedSource ; StringBuffer currentLineBuffer ; Scanner scanner ; private int [ ] constructions ; private int constructionsCount ; private int indentationLevel ; private int initialIndentationLevel ; Scanner splitScanner ; int currentCommentOffset ; int currentLineIndentationLevel ; int maxLineSize = 30 ; private boolean containsOpenCloseBraces ; private int indentationLevelForOpenCloseBraces ; private int [ ] positionsToMap ; private int [ ] mappedPositions ; private int indexToMap ; private int indexInMap ; private int globalDelta ; private int lineDelta ; private int splitDelta ; private int beginningOfLineIndex ; private int multipleLineCommentCounter ; public CodeFormatter ( ConfigurableOption [ ] settings ) { } public CodeFormatter ( ) { } public CodeFormatter ( Map settings ) { } private static boolean breakLineBeforeOperator ( int operator ) { } private static Map convertConfigurableOptions ( ConfigurableOption [ ] settings ) { } private final String copyRemainingSource ( ) { } private void dumpTab ( int tabCount ) { } private void flushBuffer ( ) { } private void format ( ) { } public String formatSourceString ( String sourceString ) { } public String format ( String string , int indentationLevel ) { } public String format ( String string , int indentationLevel , int [ ] positions ) { } public String format ( String string , int indentationLevel , int [ ] positions , String lineSeparator ) { } public String format ( String string ) { } public static String format ( String sourceString , int initialIndentationLevel , ConfigurableOption [ ] options ) { } private int getCurrentCommentOffset ( ) { } public static ConfigurableOption [ ] getDefaultOptions ( Locale locale ) { } public int [ ] getMappedPositions ( ) { } private static int getTokenPriority ( int token ) { } private boolean handleInvalidToken ( Exception e ) { } private final void increaseGlobalDelta ( int offset ) { } private final void increaseLineDelta ( int offset ) { } private final void increaseSplitDelta ( int offset ) { } private boolean insertSpaceAfter ( int token ) { } private boolean insertSpaceBefore ( int token ) { } private static boolean isComment ( int token ) { } private static boolean isLiteralToken ( int token ) { } private void newLine ( int newLineCount ) { } private String operatorString ( int operator ) { } private void output ( String stringToOutput ) { } private void outputCurrentToken ( int token ) { } private void outputLine ( String currentString , boolean preIndented , int depth , int operator , int substringIndex , int [ ] startSubstringIndexes , int offsetInGlobalLine ) { } private int pop ( int token ) { } private int popBlock ( ) { } private int popExclusiveUntil ( int token ) { } private int popExclusiveUntilBlock ( ) { } private int popExclusiveUntilBlockOrCase ( ) { } private int popInclusiveUntil ( int token ) { } private int popInclusiveUntilBlock ( ) { } private int pushBlock ( ) { } private int pushControlStatement ( int token ) { } private static boolean separateFirstArgumentOn ( int currentToken ) { } public void setPositionsToMap ( int [ ] positions ) { } private void space ( ) { } public SplitLine split ( String stringToSplit ) { } public SplitLine split ( String stringToSplit , int offsetInGlobalLine ) { } private void updateMappedPositions ( int startPosition ) { if ( ( positionsToMap ) == null ) { return ; } char [ ] source = scanner . source ; int sourceLength = source . length ; while ( ( ( indexToMap ) < ( positionsToMap . length ) ) && ( ( positionsToMap [ indexToMap ] ) <= startPosition ) ) { int posToMap = positionsToMap [ indexToMap ] ; if ( ( posToMap < 0 ) || ( posToMap >= sourceLength ) ) { if ( posToMap == sourceLength ) { mappedPositions [ indexToMap ] = formattedSource . length ( ) ; } indexToMap = positionsToMap . length ; return ; } <START_BUG> if ( Character . isWhitespace ( source [ posToMap ] ) ) { <END_BUG> mappedPositions [ indexToMap ] = ( startPosition + ( globalDelta ) ) + ( lineDelta ) ; } else { if ( posToMap == ( sourceLength - 1 ) ) { mappedPositions [ indexToMap ] = ( startPosition + ( globalDelta ) ) + ( lineDelta ) ; } else { mappedPositions [ indexToMap ] = ( posToMap + ( globalDelta ) ) + ( lineDelta ) ; } } ( indexToMap ) ++ ; } } private void updateMappedPositionsWhileSplitting ( int startPosition , int endPosition ) { } private int getLength ( String s , int tabDepth ) { } public void setInitialIndentationLevel ( int newIndentationLevel ) { } }

Fix:
if ( Scanner . isWhitespace ( source [ posToMap ] ) ) {