Buggy code:
public class NsTest extends Thread { public static final String dbName = "nstestdb" ; public static final String user = "nstest" ; public static final String password = "nstest" ; public static final String clientURL = "jdbc:derby:////localhost:1900//" ; public static final String embedURL = "jdbc:derby:" ; public static final String dataEncypt = "dataEncryption=true" ; public static final String bootPwd = "bootPassword=12345678" ; public static final String clientDbURL = new String ( ( ( ( NsTest . clientURL ) + ( NsTest . dbName ) ) + ";create=true" ) ) ; public static final String retrieveMessagePart = "retrieveMessagesFromServerOnGetMessage=true;" ; public static final String embedDbURL = new String ( ( ( ( NsTest . embedURL ) + ( NsTest . dbName ) ) + ";create=true" ) ) ; public static boolean embeddedMode = false ; public static final String driver = new String ( "org.apache.derby.jdbc.ClientDriver" ) ; public static final String embedDriver = new String ( "org.apache.derby.jdbc.EmbeddedDriver" ) ; public static Properties prop = new Properties ( ) ; public static int INIT = 0 ; public static int TESTER1 = 1 ; public static int TESTER2 = 2 ; public static int TESTER3 = 3 ; public static int BACKUP = 4 ; public static String BACKUPDIR = "backupdir" ; public static String RESTOREDIR = "restoredir" ; public static boolean START_SERVER_IN_SAME_VM = false ; public static boolean AUTO_COMMIT_OFF = false ; public static boolean CREATE_DATABASE_ONLY = false ; public static boolean schemaCreated = false ; public static int INIT_THREADS = 6 ; public static int MAX_INITIAL_ROWS = 6000 ; public static int MAX_ITERATIONS = 2000 ; public static int MAX_LOW_STRESS_ROWS = 30 ; public static int MAX_OPERATIONS_PER_CONN = 25 ; public static int NUMTESTER1 = 15 ; public static int NUMTESTER2 = 45 ; public static int NUMTESTER3 = 10 ; public static int NUM_HIGH_STRESS_ROWS = 25000 ; public static int NUM_UNTOUCHED_ROWS = 6000 ; public static int numInserts = 0 ; public static int numUpdates = 0 ; public static int numDeletes = 0 ; public static int numSelects = 0 ; public static int numFailedInserts = 0 ; public static int numFailedUpdates = 0 ; public static int numFailedDeletes = 0 ; public static int numFailedSelects = 0 ; public static int numConnections = 0 ; public static int INSERT = 0 ; public static int UPDATE = 1 ; public static int DELETE = 2 ; public static int SELECT = 3 ; public static int FAILED_INSERT = 4 ; public static int FAILED_UPDATE = 5 ; public static int FAILED_DELETE = 6 ; public static int FAILED_SELECT = 7 ; public static int CONNECTIONS_MADE = 8 ; public static final String SUCCESS = "<seq2seq4repair_space>***<seq2seq4repair_space>SUCCESS<seq2seq4repair_space>***<seq2seq4repair_space>" ; public static String driver_type = null ; private int type ; public static synchronized void addStats ( int type , int addValue ) { } NsTest ( int ttype , int k ) throws Exception { } public static void main ( String [ ] args ) throws IOException , Exception , InterruptedException , Throwable , SQLException { } public void run ( ) { } public static synchronized void printException ( String where , Exception e ) { if ( e instanceof SQLException ) { SQLException se = ( ( SQLException ) ( e ) ) ; if ( ( se . getSQLState ( ) ) != null ) { if ( se . getSQLState ( ) . equals ( "40001" ) ) System . out . println ( "deadlocked<seq2seq4repair_space>detected" ) ; if ( se . getSQLState ( ) . equals ( "40XL1" ) ) System . out . println ( "<seq2seq4repair_space>lock<seq2seq4repair_space>timeout<seq2seq4repair_space>exception" ) ; if ( se . getSQLState ( ) . equals ( "23500" ) ) System . out . println ( "<seq2seq4repair_space>duplicate<seq2seq4repair_space>key<seq2seq4repair_space>violation" ) ; } if ( ( se . getNextException ( ) ) != null ) { String m = se . getNextException ( ) . getSQLState ( ) ; System . out . println ( ( ( ( se . getNextException ( ) . getMessage ( ) ) + "<seq2seq4repair_space>SQLSTATE:<seq2seq4repair_space>" ) + m ) ) ; } } <START_BUG> if ( e . getMessage ( ) . equals ( null ) ) { <END_BUG> System . out . println ( "NULL<seq2seq4repair_space>error<seq2seq4repair_space>message<seq2seq4repair_space>detected" ) ; System . out . println ( ( "Here<seq2seq4repair_space>is<seq2seq4repair_space>the<seq2seq4repair_space>NULL<seq2seq4repair_space>exection<seq2seq4repair_space>-<seq2seq4repair_space>" + ( e . toString ( ) ) ) ) ; System . out . println ( "Stack<seq2seq4repair_space>trace<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>NULL<seq2seq4repair_space>exception<seq2seq4repair_space>-<seq2seq4repair_space>" ) ; e . printStackTrace ( System . out ) ; } System . out . println ( ( ( ( "At<seq2seq4repair_space>this<seq2seq4repair_space>point<seq2seq4repair_space>-<seq2seq4repair_space>" + where ) + ",<seq2seq4repair_space>exception<seq2seq4repair_space>thrown<seq2seq4repair_space>was<seq2seq4repair_space>:<seq2seq4repair_space>" ) + ( e . getMessage ( ) ) ) ) ; } public static String getDriverURL ( ) { } public static void startNetworkServer ( ) throws Exception { } public static void printUsage ( ) { } }

Fix:
if ( ( e . getMessage ( ) ) == null ) {