Buggy code:
@ RestController @ RequestMapping ( "//auto" ) public class AutocompleteController { @ RequestMapping ( method = RequestMethod . GET , produces = "application//json;charset=UTF-8" ) public Object getAutoComplete ( @ RequestParam ( "source" ) String source , @ RequestParam ( value = "value" , defaultValue = "full" ) String value ) { if ( source == null ) return new SimpleErrorData ( "Invalid<seq2seq4repair_space>Parameters" , "The<seq2seq4repair_space>source<seq2seq4repair_space>parameter<seq2seq4repair_space>was<seq2seq4repair_space>not<seq2seq4repair_space>provided" ) ; if ( value == null ) return new SimpleErrorData ( "Invalid<seq2seq4repair_space>Parameters" , "The<seq2seq4repair_space>value<seq2seq4repair_space>parameter<seq2seq4repair_space>was<seq2seq4repair_space>not<seq2seq4repair_space>provided" ) ; if ( ! ( source . equalsIgnoreCase ( "game" ) ) ) return new SimpleErrorData ( "Invalid<seq2seq4repair_space>Parameters" , ( ( "The<seq2seq4repair_space>source<seq2seq4repair_space>parameter<seq2seq4repair_space>value<seq2seq4repair_space>of<seq2seq4repair_space>" + source ) + "<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>a<seq2seq4repair_space>valid<seq2seq4repair_space>source<seq2seq4repair_space>value." ) ) ; GamesDatabase database = null ; Object results = null ; if ( ( value . trim ( ) . length ( ) ) < 3 ) return new ArrayList < CompactSearchData > ( ) ; try { database = MongoDBFactory . createMongoGamesDatabase ( databaseHost , databasePort , databaseName ) ; database . initializeDBConnection ( ) ; if ( value . equalsIgnoreCase ( "full" ) ) results = new com . ac . games . rest . data . WrapList ( database . readGameNamesForAutoComplete ( ) ) ; else { System . out . println ( ( "The<seq2seq4repair_space>value<seq2seq4repair_space>I'm<seq2seq4repair_space>going<seq2seq4repair_space>to<seq2seq4repair_space>deconstruct<seq2seq4repair_space>is:<seq2seq4repair_space>" + value ) ) ; String gameName = null ; String primaryPub = null ; int yearPublished = - 1 ; <START_BUG> int openParen = value . indexOf ( "(" ) ; <END_BUG> if ( openParen == ( - 1 ) ) gameName = value . trim ( ) ; else { gameName = value . substring ( 0 , ( openParen - 1 ) ) . trim ( ) ; String filterSubString = value . substring ( ( openParen + 1 ) , ( ( value . length ( ) ) - 1 ) ) ; int splitPos = filterSubString . indexOf ( "<seq2seq4repair_space>-<seq2seq4repair_space>" ) ; if ( splitPos != ( - 1 ) ) { primaryPub = filterSubString . substring ( 0 , splitPos ) . trim ( ) ; yearPublished = Integer . parseInt ( filterSubString . substring ( ( splitPos + 3 ) ) . trim ( ) ) ; } else { try { yearPublished = Integer . parseInt ( filterSubString ) ; } catch ( NumberFormatException nfe ) { primaryPub = filterSubString ; } } } System . out . println ( ( "Game<seq2seq4repair_space>Name:<seq2seq4repair_space>" + gameName ) ) ; System . out . println ( ( "Primary<seq2seq4repair_space>Pub:<seq2seq4repair_space>" + primaryPub ) ) ; System . out . println ( ( "yearPublished:<seq2seq4repair_space>" + yearPublished ) ) ; CompactSearchData data = database . readGameFromAutoName ( gameName , primaryPub , yearPublished ) ; if ( data == null ) results = new SimpleErrorData ( "No<seq2seq4repair_space>Game<seq2seq4repair_space>Found" , "I<seq2seq4repair_space>could<seq2seq4repair_space>not<seq2seq4repair_space>find<seq2seq4repair_space>the<seq2seq4repair_space>requested<seq2seq4repair_space>game." ) ; else results = data ; } } catch ( DatabaseOperationException doe ) { doe . printStackTrace ( ) ; try { if ( database != null ) database . closeDBConnection ( ) ; } catch ( Throwable t2 ) { } return new SimpleErrorData ( "Database<seq2seq4repair_space>Operation<seq2seq4repair_space>Error" , ( "An<seq2seq4repair_space>error<seq2seq4repair_space>occurred<seq2seq4repair_space>running<seq2seq4repair_space>the<seq2seq4repair_space>request:<seq2seq4repair_space>" + ( doe . getMessage ( ) ) ) ) ; } catch ( ConfigurationException ce ) { ce . printStackTrace ( ) ; try { if ( database != null ) database . closeDBConnection ( ) ; } catch ( Throwable t2 ) { } return new SimpleErrorData ( "Database<seq2seq4repair_space>Configuration<seq2seq4repair_space>Error" , ( "An<seq2seq4repair_space>error<seq2seq4repair_space>occurred<seq2seq4repair_space>accessing<seq2seq4repair_space>the<seq2seq4repair_space>database:<seq2seq4repair_space>" + ( ce . getMessage ( ) ) ) ) ; } finally { try { if ( database != null ) database . closeDBConnection ( ) ; } catch ( Throwable t2 ) { } } return results ; } }

Fix:
int openParen = value . lastIndexOf ( "(" ) ;