Buggy code:
public class Author { private static JsonObjectBuilder JSONAuthor ( ResultSet rs , JsonObjectBuilder author ) throws Exception { } private static JsonObjectBuilder JSONAuthor ( String authid , JsonObjectBuilder author ) throws Exception { } public static String add ( JsonObject payload ) { } public static String details ( final int authid ) { } public static String find ( int limit , String name ) { } public static String degree ( String authid1 , String authid2 ) { } public static String popular ( int limit , int offset , String start , String end ) { JsonObjectBuilder result = Json . createObjectBuilder ( ) ; JsonArrayBuilder authors = Json . createArrayBuilder ( ) ; JsonObjectBuilder sales = Json . createObjectBuilder ( ) ; String st = start . split ( "T" ) [ 0 ] ; String ed = end . split ( "T" ) [ 0 ] ; Connector con = null ; try { String sql = ( ( ( ( "SELECT<seq2seq4repair_space>W.authid,<seq2seq4repair_space>SUM(I.amount)<seq2seq4repair_space>as<seq2seq4repair_space>sales<seq2seq4repair_space>FROM<seq2seq4repair_space>ItemInOrder<seq2seq4repair_space>I,<seq2seq4repair_space>WrittenBy<seq2seq4repair_space>W,<seq2seq4repair_space>Orders<seq2seq4repair_space>O<seq2seq4repair_space>" + "WHERE<seq2seq4repair_space>I.isbn<seq2seq4repair_space>=<seq2seq4repair_space>W.isbn<seq2seq4repair_space>AND<seq2seq4repair_space>O.orderid<seq2seq4repair_space>=<seq2seq4repair_space>I.orderid<seq2seq4repair_space>AND<seq2seq4repair_space>O.time<seq2seq4repair_space>>=<seq2seq4repair_space>'" ) + st ) + "'<seq2seq4repair_space>AND<seq2seq4repair_space>O.time<seq2seq4repair_space><=<seq2seq4repair_space>'" ) + ed ) + "'<seq2seq4repair_space>GROUP<seq2seq4repair_space>BY<seq2seq4repair_space>W.authid<seq2seq4repair_space>ORDER<seq2seq4repair_space>BY<seq2seq4repair_space>SUM(I.amount)<seq2seq4repair_space>DESC" ; sql += ( ( "<seq2seq4repair_space>LIMIT<seq2seq4repair_space>" + limit ) + "<seq2seq4repair_space>OFFSET<seq2seq4repair_space>" ) + offset ; con = new Connector ( ) ; ResultSet rs = con . stmt . executeQuery ( sql ) ; while ( rs . next ( ) ) { final String authid = rs . getString ( "W.authid" ) ; final int _sales = rs . getInt ( "sales" ) ; JsonObjectBuilder author = Json . createObjectBuilder ( ) ; author = Author . JSONAuthor ( authid , author ) ; authors . add ( author ) ; sales . add ( authid , _sales ) ; } <START_BUG> sql = ( ( ( ( "SELECT<seq2seq4repair_space>COUNT(DISTINCT<seq2seq4repair_space>I.isbn)<seq2seq4repair_space>AS<seq2seq4repair_space>total<seq2seq4repair_space>FROM<seq2seq4repair_space>ItemInOrder<seq2seq4repair_space>I,<seq2seq4repair_space>WrittenBy<seq2seq4repair_space>W,<seq2seq4repair_space>Orders<seq2seq4repair_space>O<seq2seq4repair_space>" + "WHERE<seq2seq4repair_space>I.isbn<seq2seq4repair_space>=<seq2seq4repair_space>W.isbn<seq2seq4repair_space>AND<seq2seq4repair_space>O.orderid<seq2seq4repair_space>=<seq2seq4repair_space>I.orderid<seq2seq4repair_space>AND<seq2seq4repair_space>O.time<seq2seq4repair_space>>=<seq2seq4repair_space>'" ) + st ) + "'<seq2seq4repair_space>AND<seq2seq4repair_space>O.time<seq2seq4repair_space><=<seq2seq4repair_space>'" ) + ed ) + "'" ; <END_BUG> rs = con . stmt . executeQuery ( sql ) ; rs . next ( ) ; JsonObjectBuilder meta = Json . createObjectBuilder ( ) ; meta . add ( "total" , rs . getInt ( "total" ) ) ; result . add ( "meta" , meta ) ; if ( con != null ) con . closeConnection ( ) ; return result . add ( "authors" , authors ) . add ( "sales" , sales ) . build ( ) . toString ( ) ; } catch ( Exception e ) { System . out . println ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>query<seq2seq4repair_space>popular<seq2seq4repair_space>authors" ) ; System . err . println ( e . getMessage ( ) ) ; if ( con != null ) con . closeConnection ( ) ; return null ; } } No newline ; at end ; of file ; }

Fix:
sql = ( ( ( ( "SELECT<seq2seq4repair_space>COUNT(DISTINCT<seq2seq4repair_space>W.authid)<seq2seq4repair_space>AS<seq2seq4repair_space>total<seq2seq4repair_space>FROM<seq2seq4repair_space>ItemInOrder<seq2seq4repair_space>I,<seq2seq4repair_space>WrittenBy<seq2seq4repair_space>W,<seq2seq4repair_space>Orders<seq2seq4repair_space>O<seq2seq4repair_space>" + "WHERE<seq2seq4repair_space>I.isbn<seq2seq4repair_space>=<seq2seq4repair_space>W.isbn<seq2seq4repair_space>AND<seq2seq4repair_space>O.orderid<seq2seq4repair_space>=<seq2seq4repair_space>I.orderid<seq2seq4repair_space>AND<seq2seq4repair_space>O.time<seq2seq4repair_space>>=<seq2seq4repair_space>'" ) + st ) + "'<seq2seq4repair_space>AND<seq2seq4repair_space>O.time<seq2seq4repair_space><=<seq2seq4repair_space>'" ) + ed ) + "'" ;