#vulnerable code 
                              @Test
  public void testDeletingRecurrentQueueWithHistory() throws Exception {
    final String queueName = TestHelper.getTestMethodName();
    int intervalSeconds = 3;

    // Create a queue
    LOG.info("Starting job-queue: " + queueName);
    JobQueue.Builder queueBuild = TaskTestUtil.buildRecurrentJobQueue(queueName, 0, 60,
        TargetState.STOP);
    createAndEnqueueJob(queueBuild, 2);

    _driver.createQueue(queueBuild.build());
    WorkflowConfig workflowConfig = _driver.getWorkflowConfig(queueName);
    Assert.assertEquals(workflowConfig.getTargetState(), TargetState.STOP);

    // reset interval to a smaller number so as to accelerate test
    workflowConfig.putSimpleConfig(WorkflowConfig.WorkflowConfigProperty.RecurrenceInterval.name(),
        "" + intervalSeconds);
    _driver.updateWorkflow(queueName, workflowConfig);

    _driver.resume(queueName);

    WorkflowContext wCtx;
    // wait until at least 2 workflows are scheduled based on template queue
    do {
      Thread.sleep(intervalSeconds);
      wCtx = TaskTestUtil.pollForWorkflowContext(_driver, queueName);
    } while (wCtx.getScheduledWorkflows().size() < 2);

    // Stop recurring workflow
    _driver.stop(queueName);
    _driver.pollForWorkflowState(queueName, TaskState.STOPPED);

    // Record all scheduled workflows
    wCtx = TaskTestUtil.pollForWorkflowContext(_driver, queueName);
    List<String> scheduledWorkflows = new ArrayList<String>(wCtx.getScheduledWorkflows());
    final String lastScheduledWorkflow = wCtx.getLastScheduledSingleWorkflow();

    // Delete recurrent workflow
    _driver.delete(queueName);

    // Wait until recurrent workflow and the last scheduled workflow are cleaned up
    boolean result = TestHelper.verify(new TestHelper.Verifier() {
      @Override public boolean verify() throws Exception {
        WorkflowContext wCtx = _driver.getWorkflowContext(queueName);
        WorkflowContext lastWfCtx = _driver.getWorkflowContext(lastScheduledWorkflow);
        return (wCtx == null && lastWfCtx == null);
      }
    }, 5 * 1000);
    Assert.assertTrue(result);

    for (String scheduledWorkflow : scheduledWorkflows) {
      WorkflowContext scheduledWorkflowCtx = _driver.getWorkflowContext(scheduledWorkflow);
      WorkflowConfig scheduledWorkflowCfg = _driver.getWorkflowConfig(scheduledWorkflow);
      Assert.assertNull(scheduledWorkflowCtx);
      Assert.assertNull(scheduledWorkflowCfg);
    }
  } 
                            #location 14 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                              @Test
  public void testDeletingRecurrentQueueWithHistory() throws Exception {
    final String queueName = TestHelper.getTestMethodName();

    // Create a queue
    LOG.info("Starting job-queue: " + queueName);
    JobQueue.Builder queueBuild = TaskTestUtil.buildRecurrentJobQueue(queueName, 0, 60,
        TargetState.STOP);
    createAndEnqueueJob(queueBuild, 2);

    _driver.createQueue(queueBuild.build());
    WorkflowConfig workflowConfig = _driver.getWorkflowConfig(queueName);
    Assert.assertEquals(workflowConfig.getTargetState(), TargetState.STOP);

    _driver.resume(queueName);

    WorkflowContext wCtx;
    // wait until at least 2 workflows are scheduled based on template queue
    do {
      Thread.sleep(60000);
      wCtx = TaskTestUtil.pollForWorkflowContext(_driver, queueName);
    } while (wCtx.getScheduledWorkflows().size() < 2);

    // Stop recurring workflow
    _driver.stop(queueName);
    _driver.pollForWorkflowState(queueName, TaskState.STOPPED);

    // Record all scheduled workflows
    wCtx = TaskTestUtil.pollForWorkflowContext(_driver, queueName);
    List<String> scheduledWorkflows = new ArrayList<String>(wCtx.getScheduledWorkflows());
    final String lastScheduledWorkflow = wCtx.getLastScheduledSingleWorkflow();

    // Delete recurrent workflow
    _driver.delete(queueName);

    // Wait until recurrent workflow and the last scheduled workflow are cleaned up
    boolean result = TestHelper.verify(new TestHelper.Verifier() {
      @Override public boolean verify() throws Exception {
        WorkflowContext wCtx = _driver.getWorkflowContext(queueName);
        WorkflowContext lastWfCtx = _driver.getWorkflowContext(lastScheduledWorkflow);
        return (wCtx == null && lastWfCtx == null);
      }
    }, 5 * 1000);
    Assert.assertTrue(result);

    for (String scheduledWorkflow : scheduledWorkflows) {
      WorkflowContext scheduledWorkflowCtx = _driver.getWorkflowContext(scheduledWorkflow);
      WorkflowConfig scheduledWorkflowCfg = _driver.getWorkflowConfig(scheduledWorkflow);
      Assert.assertNull(scheduledWorkflowCtx);
      Assert.assertNull(scheduledWorkflowCfg);
    }
  }