Buggy code:
public String [ ] allUserTags ( String where ) { } public void updateFactTags ( long [ ] factIds ) { } public void updateCardTags ( ) { } public void updateCardTags ( long [ ] cardIds ) { } public ArrayList < HashMap < String , String > > getCards ( int chunk , String startId ) { } public int getMarketTagId ( ) { } public void resetMarkedTagId ( ) { } public ArrayList < String > factTags ( long [ ] factIds ) { } public void addTag ( long factId , String tag ) { } public void addTag ( long [ ] factIds , String tag ) { } public void deleteTag ( long factId , String tag ) { } public void deleteTag ( long [ ] factIds , String tag ) { } public void suspendCards ( long [ ] ids ) { } public void unsuspendCards ( long [ ] ids ) { } public boolean getSuspendedState ( long id ) { } public void buryFact ( long factId , long cardId ) { } public void updateAllPriorities ( ) { } public void updateAllPriorities ( boolean partial ) { } public void updateAllPriorities ( boolean partial , boolean dirty ) { } private HashMap < Long , Integer > updateTagPriorities ( ) { } private void updatePriorities ( long [ ] cardIds ) { } void updatePriorities ( long [ ] cardIds , String [ ] suspend , boolean dirty ) { } private int newCardsDoneToday ( ) { } public void deleteCards ( List < String > ids ) { } public Fact addFact ( Fact fact , HashMap < Long , CardModel > cardModels ) { } public Fact addFact ( Fact fact , HashMap < Long , CardModel > cardModels , boolean reset ) { } public boolean importFact ( Fact fact , CardModel cardModel ) { } public void deleteFacts ( List < String > ids ) { } private ArrayList < String > deleteDanglingFacts ( ) { } public void deleteModel ( String id ) { } public void deleteFieldModel ( String modelId , String fieldModelId ) { } public void deleteCardModel ( String modelId , String cardModelId ) { } private class UndoRow { private String mName ; private Long mCardId ; private ArrayList < Deck . UndoCommand > mUndoCommands ; UndoRow ( String name , Long cardId ) { } } private class UndoCommand { private SqlCommandType mCommand ; private String mTable ; private ContentValues mValues ; private String mWhereClause ; UndoCommand ( SqlCommandType command , String table , ContentValues values , String whereClause ) { } } private void initUndo ( ) { } public String undoName ( ) { } public String redoName ( ) { } public boolean undoAvailable ( ) { } public boolean redoAvailable ( ) { } public void resetUndo ( ) { } public void setUndoStart ( String name ) { } public void setUndoStart ( String name , long cardId ) { } public void setReviewEarly ( boolean reviewEarly ) { } private void setUndoStart ( String name , long cardId , boolean merge ) { } public void setUndoEnd ( String name ) { } private void startRecordingUndoInfo ( Stack < Deck . UndoRow > dst ) { } private void stopRecordingUndoInfo ( ) { } public boolean recordUndoInformation ( ) { } public void addUndoCommand ( SqlCommandType command , String table , ContentValues values , String whereClause ) { } private long undoredo ( Stack < Deck . UndoRow > src , Stack < Deck . UndoRow > dst , long oldCardId , boolean inReview ) { } public long undo ( long oldCardId , boolean inReview ) { } public long redo ( long oldCardId , boolean inReview ) { } public String getUndoType ( ) { } private void updateDynamicIndices ( ) { } public JSONObject bundleJson ( JSONObject bundledDeck ) { } public void updateFromJson ( JSONObject deckPayload ) { } private long tagId ( String tag , Boolean create ) { } private HashMap < String , Long > tagIds ( String [ ] tags ) { } private HashMap < String , Long > tagIds ( String [ ] tags , boolean create ) { HashMap < String , Long > results = new HashMap < String , Long > ( ) ; if ( create ) { for ( String tag : tags ) { getDB ( ) . getDatabase ( ) . execSQL ( ( ( "INSERT<seq2seq4repair_space>OR<seq2seq4repair_space>IGNORE<seq2seq4repair_space>INTO<seq2seq4repair_space>tags<seq2seq4repair_space>(tag)<seq2seq4repair_space>VALUES<seq2seq4repair_space>('" + ( tag . replace ( "'" , "''" ) ) ) + "')" ) ) ; } } if ( ( tags . length ) != 0 ) { StringBuilder tagList = new StringBuilder ( 128 ) ; for ( int i = 0 ; i < ( tags . length ) ; i ++ ) { tagList . append ( "'" ) . append ( tags [ i ] ) . append ( "'" ) ; if ( i < ( ( tags . length ) - 1 ) ) { tagList . append ( ",<seq2seq4repair_space>" ) ; } } Cursor cur = null ; try { <START_BUG> cur = getDB ( ) . getDatabase ( ) . rawQuery ( ( ( "SELECT<seq2seq4repair_space>tag,<seq2seq4repair_space>id<seq2seq4repair_space>FROM<seq2seq4repair_space>tags<seq2seq4repair_space>WHERE<seq2seq4repair_space>tag<seq2seq4repair_space>in<seq2seq4repair_space>(" + ( tagList . toString ( ) ) ) + ")" ) , null ) ; <END_BUG> while ( cur . moveToNext ( ) ) { results . put ( cur . getString ( 0 ) . toLowerCase ( ) , cur . getLong ( 1 ) ) ; } } finally { if ( ( cur != null ) && ( ! ( cur . isClosed ( ) ) ) ) { cur . close ( ) ; } } } return results ; } public static synchronized void initializeEmptyDeck ( String deckPath ) { } public ContentValues getDeckSummary ( ) { } public static boolean isWalEnabled ( String deckPath ) { } }

Fix:
cur = getDB ( ) . getDatabase ( ) . rawQuery ( ( ( "SELECT<seq2seq4repair_space>tag,<seq2seq4repair_space>id<seq2seq4repair_space>FROM<seq2seq4repair_space>tags<seq2seq4repair_space>WHERE<seq2seq4repair_space>tag<seq2seq4repair_space>in<seq2seq4repair_space>(" + ( tagList . toString ( ) . replaceAll ( "\\\'+" , "\'\'" ) ) ) + ")" ) , null ) ;