#fixed code
                             @Test
	public void testUpsertSelectSameBatchConcurrently() throws Exception {
		try (Connection conn = driver.connect(url, props)) {
		        int numUpsertSelectRunners = 5;
		        ExecutorService exec = Executors.newFixedThreadPool(numUpsertSelectRunners);
		        CompletionService<Boolean> completionService = new ExecutorCompletionService<Boolean>(exec);
		        List<Future<Boolean>> futures = Lists.newArrayListWithExpectedSize(numUpsertSelectRunners);
		        // run one UPSERT SELECT for 100 rows (that locks the rows for a long time)
		        futures.add(completionService.submit(new UpsertSelectRunner(dataTable, 0, 105, 1)));
		        // run four UPSERT SELECTS for 5 rows (that overlap with slow running UPSERT SELECT)
		        for (int i = 0; i < 100; i += 25) {
		            futures.add(completionService.submit(new UpsertSelectRunner(dataTable, i, i+25, 5)));
		        }
		        int received = 0;
		        while (received < futures.size()) {
		            Future<Boolean> resultFuture = completionService.take();
		            Boolean result = resultFuture.get();
		            received++;
		            assertTrue(result);
		        }
		        exec.shutdownNow();
		}
	}
#vulnerable code 
                             @Test
	public void testUpsertSelectSameBatchConcurrently() throws Exception {
		final String dataTable = generateUniqueName();
		final String index = "IDX_" + dataTable;
		// create the table and ensure its empty
		Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
		Connection conn = driver.connect(url, props);
		conn.createStatement()
				.execute("CREATE TABLE " + dataTable + " (k INTEGER NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
		// create the index and ensure its empty as well
		conn.createStatement().execute("CREATE INDEX " + index + " ON " + dataTable + " (v1)");

		conn = DriverManager.getConnection(getUrl(), props);
		PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + dataTable + " VALUES(?,?,?)");
		conn.setAutoCommit(false);
		for (int i = 0; i < 100; i++) {
			stmt.setInt(1, i);
			stmt.setString(2, "v1" + i);
			stmt.setString(3, "v2" + i);
			stmt.execute();
		}
		conn.commit();

		int numUpsertSelectRunners = 5;
		ExecutorService exec = Executors.newFixedThreadPool(numUpsertSelectRunners);
		CompletionService<Boolean> completionService = new ExecutorCompletionService<Boolean>(exec);
		List<Future<Boolean>> futures = Lists.newArrayListWithExpectedSize(numUpsertSelectRunners);
		// run one UPSERT SELECT for 100 rows (that locks the rows for a long time)
		futures.add(completionService.submit(new UpsertSelectRunner(dataTable, 0, 105, 1)));
		// run four UPSERT SELECTS for 5 rows (that overlap with slow running UPSERT SELECT)
		for (int i = 0; i < 100; i += 25) {
			futures.add(completionService.submit(new UpsertSelectRunner(dataTable, i, i+25, 5)));
		}
		int received = 0;
		while (received < futures.size()) {
			Future<Boolean> resultFuture = completionService.take(); 
			Boolean result = resultFuture.get();
			received++;
			assertTrue(result);
		}
		exec.shutdownNow();
		conn.close();
	} 
                            #location 8 
                            #vulnerability type NULL_DEREFERENCE