Buggy code:
public class DatabaseManager { public static boolean userAllowedToOpenTreasure ( int bid , int uid ) throws SQLException { } public static int saveTreasure ( Treasure toSave ) throws IllegalArgumentException , SQLException { <START_BUG> if ( ( ( toSave . getId ( ) ) != ( - 1 ) ) && ( ( toSave . getXP ( ) ) != ( - 1 ) ) ) <END_BUG> throw new IllegalArgumentException ( ) ; Location lTmp = toSave . getLocation ( ) ; int lid ; if ( ( lTmp . getId ( ) ) == ( - 1 ) ) lid = DatabaseManager . insertLocation ( lTmp . getLon ( ) , lTmp . getLat ( ) , lTmp . getXP ( ) ) ; else lid = lTmp . getId ( ) ; Integer tid ; Integer qid ; if ( ( toSave . getType ( ) ) instanceof Quiz ) { Quiz qTmp = ( ( Quiz ) ( toSave . getType ( ) ) ) ; if ( ( qTmp . getId ( ) ) == ( - 1 ) ) tid = DatabaseManager . insertType ( qTmp . getType ( ) ) ; else tid = qTmp . getId ( ) ; if ( ( qTmp . getQuizId ( ) ) == ( - 1 ) ) { Integer qLid ; if ( ( qTmp . getLocationId ( ) ) == ( - 1 ) ) qLid = null ; else qLid = qTmp . getLocationId ( ) ; qid = DatabaseManager . insertQuiz ( qTmp . getQuestion ( ) , qTmp . getAnswer1 ( ) , qTmp . getAnswer2 ( ) , qTmp . getAnswer3 ( ) , qTmp . getAnswer4 ( ) , qTmp . getAnswer5 ( ) , qTmp . getAnswer6 ( ) , qTmp . getXP ( ) , qLid ) ; } else qid = qTmp . getQuizId ( ) ; } else { tid = null ; qid = null ; } Size sTmp = toSave . getSize ( ) ; int sid ; if ( ( sTmp . getId ( ) ) == ( - 1 ) ) sid = DatabaseManager . insertSize ( sTmp . getSize ( ) , sTmp . getXP ( ) ) ; else sid = sTmp . getId ( ) ; Integer cid = DatabaseManager . insertContent ( toSave . getContent ( ) ) ; Integer treasureID = DatabaseManager . insertBox ( lid , tid , sid , qid , cid ) ; return treasureID ; } public static Integer insertBox ( Integer lid , Integer tid , int sid , Integer qid , Integer cid ) throws SQLException { } public static Integer insertQuiz ( String question , String correct1 , String answer2 , String answer3 , String answer4 , String answer5 , String answer6 , int exp , Integer lid ) throws IllegalArgumentException , SQLException { } public static Integer insertSize ( int size , int exp ) throws SQLException { } public static Integer insertContent ( Treasure . Content content ) throws IllegalArgumentException , SQLException { } public static Integer insertLocation ( Double x , Double y , int exp ) throws SQLException { } public static Integer insertType ( String name ) throws IllegalArgumentException , SQLException { } public static Integer insertUser ( User user ) throws SQLException { } public static Integer insertUser ( String name , String pwdHash , String email ) throws SQLException { } public static boolean insertHistory ( int uid , int bid ) throws SQLException { } public static boolean insertInInventory ( int uid , int cid ) throws SQLException { } public static boolean deleteUser ( int uid ) throws SQLException { } public static void deleteHistory ( int uid ) throws SQLException { } public static void deleteInventory ( int uid ) throws SQLException { } public static boolean deleteTreasure ( int tid ) throws SQLException { } public static boolean deleteLocation ( int lid ) throws SQLException { } public static boolean deleteType ( int tid ) throws SQLException { } public static boolean deleteSize ( int sid ) throws SQLException { } public static boolean deleteQuiz ( int qid ) throws SQLException { } public static boolean deleteContent ( int cid ) throws SQLException { } public static void deleteAll ( ) throws SQLException { } private static Connection getConnection ( ) throws SQLException { } public static Quiz getQuizFromId ( int qid ) throws SQLException { } public static Location getLocationFromId ( int lid ) throws SQLException { } public static Size getSizeFromId ( int sid ) throws SQLException { } public static Content getContentFromId ( int cid ) throws SQLException { } private static Type setTypeAttributesFromId ( int tid , Type toset ) throws SQLException { } public static Treasure getTreasureFromId ( int bid ) throws SQLException { } public static ArrayList < Treasure > getAllTreasures ( ) throws SQLException { } public static Location getLocationFromBid ( int bid ) throws SQLException { } public static User getUserFromId ( int uid ) throws SQLException { } public static User getUserProfileFromId ( int uid ) throws SQLException { } public static User getUserFromName ( String name ) throws SQLException { } public static User getUserProfileFromName ( String name ) throws SQLException { } private static int getScoreFromId ( int uid ) throws IllegalArgumentException , SQLException { } public static int getRankFromId ( int uid ) throws IllegalArgumentException , SQLException { } public static Inventory getUserInventory ( int uId ) throws SQLException { } public static HighscoreList getHighScoreFromTo ( int fromRank , int numberOfEntries ) throws SQLException { } public static boolean updateScore ( int uid , int score ) throws SQLException { } public static Map < Treasure , Long > getHistory ( int uid ) throws SQLException { } public static boolean changePassword ( int uid , String newPwdHash ) throws IllegalArgumentException , SQLException { } public static List < Integer > getAllBoxId ( ) throws SQLException { }

Fix:
if ( ( ( toSave . getId ( ) ) != ( - 1 ) ) && ( ! ( toSave . isValidTreasure ( ) ) ) )