nus-yam/ex-repair huggingface dataset:
Program: 4729
Project: 4729
Buggy source:
@Test public void testPossessDoesDelete() throws IOException, DatasetManagementException {
  String existingPath=tmpFolder.newFolder() + "String_Node_Str";
  File existingDir=new File(existingPath);
  existingDir.mkdirs();
  File someFile=new File(existingDir,"String_Node_Str");
  someFile.createNewFile();
  dsFrameworkUtil.createInstance("String_Node_Str",testFileSetInstance5,FileSetProperties.builder().setBasePath(existingPath).setPossessExisting(true).build());
  Assert.assertTrue(someFile.exists());
  dsFrameworkUtil.getFramework().truncateInstance(testFileSetInstance5);
  Assert.assertFalse(someFile.exists());
  Assert.assertTrue(existingDir.exists());
  someFile.createNewFile();
  dsFrameworkUtil.getFramework().deleteInstance(testFileSetInstance5);
  Assert.assertFalse(someFile.exists());
  Assert.assertFalse(existingDir.exists());
}

Fixed version (ground truth):
@Test public void testPossessDoesDelete() throws IOException, DatasetManagementException {
  String existingPath=tmpFolder.newFolder() + "String_Node_Str";
  File existingDir=new File(existingPath);
  existingDir.mkdirs();
  File someFile=new File(existingDir,"String_Node_Str");
  someFile.createNewFile();
  dsFrameworkUtil.createInstance("String_Node_Str",testFileSetInstance5,FileSetProperties.builder().setBasePath(existingPath).setPossessExisting(true).build());
  Assert.assertTrue(someFile.exists());
  FileSet fs=dsFrameworkUtil.getInstance(testFileSetInstance5);
  Location base=fs.getBaseLocation();
  String permissions=base.getPermissions();
  char groupWriteFlag=permissions.charAt(4);
  char toggledGroupWriteFlag=groupWriteFlag == 'w' ? '-' : 'w';
  String toggledPermissions=permissions.substring(0,4) + toggledGroupWriteFlag + permissions.substring(5,9);
  base.setPermissions(toggledPermissions);
  dsFrameworkUtil.getFramework().truncateInstance(testFileSetInstance5);
  Assert.assertFalse(someFile.exists());
  Assert.assertTrue(existingDir.exists());
  Assert.assertEquals(toggledPermissions,base.getPermissions());
  someFile.createNewFile();
  dsFrameworkUtil.getFramework().deleteInstance(testFileSetInstance5);
  Assert.assertFalse(someFile.exists());
  Assert.assertFalse(existingDir.exists());
}
Program: 4731
Project: 4731
Buggy source:
@Override public void destroy(){
  super.destroy();
  ProgramStatus status=getContext().getState().getStatus();
  WRAPPERLOGGER.info("String_Node_Str",getContext().getApplicationSpecification().getName(),status == ProgramStatus.COMPLETED ? "String_Node_Str" : status.name().toLowerCase());
}

Fixed version (ground truth):
@TransactionPolicy(TransactionControl.EXPLICIT) @Override public void destroy(){
  super.destroy();
  ProgramStatus status=getContext().getState().getStatus();
  WRAPPERLOGGER.info("String_Node_Str",getContext().getApplicationSpecification().getName(),status == ProgramStatus.COMPLETED ? "String_Node_Str" : status.name().toLowerCase());
}
Program: 4733
Project: 4733
Buggy source:
/** 
 * Prepare the Batch run. Used to configure the job before starting the run.
 * @param context batch execution context
 * @throws Exception if there's an error during this method invocation
 */
public abstract void prepareRun(T context) throws Exception ;

Fixed version (ground truth):
/** 
 * Prepare the Batch run. Used to configure the job before starting the run.
 * @param context batch execution context
 * @throws Exception if there's an error during this method invocation
 */
@Override public abstract void prepareRun(T context) throws Exception ;
Program: 4734
Project: 4734
Buggy source:
/** 
 * Invoked after the Batch run finishes. Used to perform any end of the run logic.
 * @param succeeded defines the result of batch execution: true if run succeeded, false otherwise
 * @param context batch execution context
 */
public void onRunFinish(boolean succeeded,T context){
}

Fixed version (ground truth):
/** 
 * Invoked after the Batch run finishes. Used to perform any end of the run logic.
 * @param succeeded defines the result of batch execution: true if run succeeded, false otherwise
 * @param context batch execution context
 */
@Override public void onRunFinish(boolean succeeded,T context){
}
Program: 4735
Project: 4735
Buggy source:
/** 
 * Prepare the Batch run. Used to configure the job before starting the run.
 * @param context batch execution context
 * @throws Exception if there's an error during this method invocation
 */
public abstract void prepareRun(T context) throws Exception ;

Fixed version (ground truth):
/** 
 * Prepare the Batch run. Used to configure the job before starting the run.
 * @param context batch execution context
 * @throws Exception if there's an error during this method invocation
 */
@Override public abstract void prepareRun(T context) throws Exception ;
Program: 4736
Project: 4736
Buggy source:
/** 
 * Invoked after the Batch run finishes. Used to perform any end of the run logic.
 * @param succeeded defines the result of batch execution: true if run succeeded, false otherwise
 * @param context batch execution context
 */
public void onRunFinish(boolean succeeded,T context){
}

Fixed version (ground truth):
/** 
 * Invoked after the Batch run finishes. Used to perform any end of the run logic.
 * @param succeeded defines the result of batch execution: true if run succeeded, false otherwise
 * @param context batch execution context
 */
@Override public void onRunFinish(boolean succeeded,T context){
}
Program: 4737
Project: 4737
Buggy source:
@Override public void destroy(){
  WorkflowContext workflowContext=getContext();
  PipelineRuntime pipelineRuntime=new PipelineRuntime(workflowContext,workflowMetrics);
  if (workflowContext.getDataTracer(PostAction.PLUGIN_TYPE).isEnabled()) {
    return;
  }
  for (  Map.Entry<String,PostAction> endingActionEntry : postActions.entrySet()) {
    String name=endingActionEntry.getKey();
    PostAction action=endingActionEntry.getValue();
    StageSpec stageSpec=postActionSpecs.get(name);
    BatchActionContext context=new WorkflowBackedActionContext(workflowContext,pipelineRuntime,stageSpec);
    try {
      action.run(context);
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",name,t);
    }
  }
}

Fixed version (ground truth):
@TransactionPolicy(TransactionControl.EXPLICIT) @Override public void destroy(){
  WorkflowContext workflowContext=getContext();
  PipelineRuntime pipelineRuntime=new PipelineRuntime(workflowContext,workflowMetrics);
  if (workflowContext.getDataTracer(PostAction.PLUGIN_TYPE).isEnabled()) {
    return;
  }
  for (  Map.Entry<String,PostAction> endingActionEntry : postActions.entrySet()) {
    String name=endingActionEntry.getKey();
    PostAction action=endingActionEntry.getValue();
    StageSpec stageSpec=postActionSpecs.get(name);
    BatchActionContext context=new WorkflowBackedActionContext(workflowContext,pipelineRuntime,stageSpec);
    try {
      action.run(context);
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",name,t);
    }
  }
}
Program: 4738
Project: 4738
Buggy source:
@Override public void initialize(WorkflowContext context) throws Exception {
  super.initialize(context);
  postActions=new LinkedHashMap<>();
  BatchPipelineSpec batchPipelineSpec=GSON.fromJson(context.getWorkflowSpecification().getProperty("String_Node_Str"),BatchPipelineSpec.class);
  MacroEvaluator macroEvaluator=new DefaultMacroEvaluator(context.getToken(),context.getRuntimeArguments(),context.getLogicalStartTime(),context,context.getNamespace());
  postActionSpecs=new HashMap<>();
  for (  ActionSpec actionSpec : batchPipelineSpec.getEndingActions()) {
    String name=actionSpec.getName();
    postActions.put(name,(PostAction)context.newPluginInstance(name,macroEvaluator));
    postActionSpecs.put(name,StageSpec.builder(name,actionSpec.getPluginSpec()).setProcessTimingEnabled(batchPipelineSpec.isProcessTimingEnabled()).setStageLoggingEnabled(batchPipelineSpec.isStageLoggingEnabled()).build());
  }
}

Fixed version (ground truth):
@TransactionPolicy(TransactionControl.EXPLICIT) @Override public void initialize(WorkflowContext context) throws Exception {
  super.initialize(context);
  postActions=new LinkedHashMap<>();
  BatchPipelineSpec batchPipelineSpec=GSON.fromJson(context.getWorkflowSpecification().getProperty("String_Node_Str"),BatchPipelineSpec.class);
  MacroEvaluator macroEvaluator=new DefaultMacroEvaluator(context.getToken(),context.getRuntimeArguments(),context.getLogicalStartTime(),context,context.getNamespace());
  postActionSpecs=new HashMap<>();
  for (  ActionSpec actionSpec : batchPipelineSpec.getEndingActions()) {
    String name=actionSpec.getName();
    postActions.put(name,(PostAction)context.newPluginInstance(name,macroEvaluator));
    postActionSpecs.put(name,StageSpec.builder(name,actionSpec.getPluginSpec()).setProcessTimingEnabled(batchPipelineSpec.isProcessTimingEnabled()).setStageLoggingEnabled(batchPipelineSpec.isStageLoggingEnabled()).build());
  }
}
Program: 4739
Project: 4739
Buggy source:
private void verifyResponse(HttpResponseStatus expected,HttpResponseStatus actual,String errorMsg){
  if (!expected.equals(actual)) {
    throw new IllegalStateException(String.format("String_Node_Str",expected,actual,errorMsg));
  }
}

Fixed version (ground truth):
private void verifyResponse(HttpResponseStatus expected,HttpResponseStatus actual,String errorMsg){
  if (!expected.equals(actual)) {
    if (actual.getCode() == HttpResponseStatus.FORBIDDEN.getCode()) {
      throw new UnauthorizedException(actual.getReasonPhrase());
    }
    throw new IllegalStateException(String.format("String_Node_Str",expected,actual,errorMsg));
  }
}
Program: 4740
Project: 4740
Buggy source:
/** 
 * Perform the request, returning the response. If there was a ConnectException while making the request, a ServiceUnavailableException is thrown.
 * @param request the request to perform
 * @return the response
 * @throws IOException if there was an IOException while performing the request
 * @throws ServiceUnavailableException if there was a ConnectException while making the request, or if the responsewas a 503
 */
public HttpResponse execute(HttpRequest request) throws IOException {
  try {
    HttpResponse response=HttpRequests.execute(request,httpRequestConfig);
    if (response.getResponseCode() == HttpURLConnection.HTTP_UNAVAILABLE) {
      throw new ServiceUnavailableException(discoverableServiceName,response.getResponseBodyAsString());
    }
    return response;
  }
 catch (  ConnectException e) {
    throw new ServiceUnavailableException(discoverableServiceName,e);
  }
}

Fixed version (ground truth):
/** 
 * Perform the request, returning the response. If there was a ConnectException while making the request, a ServiceUnavailableException is thrown.
 * @param request the request to perform
 * @return the response
 * @throws IOException if there was an IOException while performing the request
 * @throws ServiceUnavailableException if there was a ConnectException while making the request, or if the responsewas a 503
 */
public HttpResponse execute(HttpRequest request) throws IOException {
  try {
    HttpResponse response=HttpRequests.execute(request,httpRequestConfig);
switch (response.getResponseCode()) {
case HttpURLConnection.HTTP_UNAVAILABLE:
      throw new ServiceUnavailableException(discoverableServiceName,response.getResponseBodyAsString());
case HttpURLConnection.HTTP_FORBIDDEN:
    throw new UnauthorizedException(response.getResponseBodyAsString());
default :
  return response;
}
}
 catch (ConnectException e) {
throw new ServiceUnavailableException(discoverableServiceName,e);
}
}
Program: 4741
Project: 4741
Buggy source:
/** 
 * Deletes all   {@link DatasetModuleMeta dataset modules} in the specified {@link NamespaceId namespace}.
 */
public void deleteAll(NamespaceId namespaceId) throws Exception {
  if (NamespaceId.SYSTEM.equals(namespaceId)) {
    throw new UnauthorizedException(String.format("String_Node_Str",namespaceId));
  }
  ensureNamespaceExists(namespaceId);
  try {
    typeManager.deleteModules(namespaceId);
  }
 catch (  DatasetModuleConflictException e) {
    throw new ConflictException(e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Deletes all   {@link DatasetModuleMeta dataset modules} in the specified {@link NamespaceId namespace}.
 */
public void deleteAll(NamespaceId namespaceId) throws Exception {
  if (NamespaceId.SYSTEM.equals(namespaceId)) {
    throw new UnsupportedOperationException(String.format("String_Node_Str",namespaceId));
  }
  ensureNamespaceExists(namespaceId);
  try {
    typeManager.deleteModules(namespaceId);
  }
 catch (  DatasetModuleConflictException e) {
    throw new ConflictException(e.getMessage(),e);
  }
}
Program: 4742
Project: 4742
Buggy source:
/** 
 * Deletes the specified   {@link DatasetModuleId}
 */
public void delete(DatasetModuleId datasetModuleId) throws Exception {
  NamespaceId namespaceId=datasetModuleId.getParent();
  if (NamespaceId.SYSTEM.equals(namespaceId)) {
    throw new UnauthorizedException(String.format("String_Node_Str",datasetModuleId.getModule(),datasetModuleId.getNamespace()));
  }
  ensureNamespaceExists(namespaceId);
  DatasetModuleMeta moduleMeta=typeManager.getModule(datasetModuleId);
  if (moduleMeta == null) {
    throw new DatasetModuleNotFoundException(datasetModuleId);
  }
  try {
    typeManager.deleteModule(datasetModuleId);
  }
 catch (  DatasetModuleConflictException e) {
    throw new DatasetModuleCannotBeDeletedException(datasetModuleId,e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Deletes the specified   {@link DatasetModuleId}
 */
public void delete(DatasetModuleId datasetModuleId) throws Exception {
  NamespaceId namespaceId=datasetModuleId.getParent();
  if (NamespaceId.SYSTEM.equals(namespaceId)) {
    throw new UnsupportedOperationException(String.format("String_Node_Str",datasetModuleId.getModule(),datasetModuleId.getNamespace()));
  }
  ensureNamespaceExists(namespaceId);
  DatasetModuleMeta moduleMeta=typeManager.getModule(datasetModuleId);
  if (moduleMeta == null) {
    throw new DatasetModuleNotFoundException(datasetModuleId);
  }
  try {
    typeManager.deleteModule(datasetModuleId);
  }
 catch (  DatasetModuleConflictException e) {
    throw new DatasetModuleCannotBeDeletedException(datasetModuleId,e.getMessage());
  }
}
Program: 4743
Project: 4743
Buggy source:
/** 
 * Adds a new   {@link DatasetModule}.
 * @param datasetModuleId the {@link DatasetModuleId} for the module to be added
 * @param className the module class name specified in the HTTP header
 * @param forceUpdate if true, an update will be allowed even if there are conflicts with other modules, or ifremoval of a type would break other modules' dependencies
 * @return a {@link BodyConsumer} to upload the module jar in chunks
 * @throws NotFoundException if the namespace in which the module is being added is not found
 * @throws IOException if there are issues while performing I/O like creating temporary directories, moving/unpackingmodule jar files
 * @throws DatasetModuleConflictException if #forceUpdate is {@code false}, and there are conflicts with other modules
 */
public BodyConsumer addModule(final DatasetModuleId datasetModuleId,final String className,final boolean forceUpdate) throws Exception {
  NamespaceId namespaceId=datasetModuleId.getParent();
  if (NamespaceId.SYSTEM.equals(namespaceId)) {
    throw new UnauthorizedException(String.format("String_Node_Str",datasetModuleId.getModule(),datasetModuleId.getNamespace()));
  }
  ensureNamespaceExists(namespaceId);
  try {
    return createModuleConsumer(datasetModuleId,className,forceUpdate);
  }
 catch (  Exception e) {
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Adds a new   {@link DatasetModule}.
 * @param datasetModuleId the {@link DatasetModuleId} for the module to be added
 * @param className the module class name specified in the HTTP header
 * @param forceUpdate if true, an update will be allowed even if there are conflicts with other modules, or ifremoval of a type would break other modules' dependencies
 * @return a {@link BodyConsumer} to upload the module jar in chunks
 * @throws NotFoundException if the namespace in which the module is being added is not found
 * @throws IOException if there are issues while performing I/O like creating temporary directories, moving/unpackingmodule jar files
 * @throws DatasetModuleConflictException if #forceUpdate is {@code false}, and there are conflicts with other modules
 */
public BodyConsumer addModule(final DatasetModuleId datasetModuleId,final String className,final boolean forceUpdate) throws Exception {
  NamespaceId namespaceId=datasetModuleId.getParent();
  if (NamespaceId.SYSTEM.equals(namespaceId)) {
    throw new UnsupportedOperationException(String.format("String_Node_Str",datasetModuleId.getModule(),datasetModuleId.getNamespace()));
  }
  ensureNamespaceExists(namespaceId);
  try {
    return createModuleConsumer(datasetModuleId,className,forceUpdate);
  }
 catch (  Exception e) {
    throw e;
  }
}
Program: 4744
Project: 4744
Buggy source:
/** 
 * This test is to make sure we do not bypass the authorization check for datasets in system namespace
 */
@Test public void testDeleteSystemDatasets() throws Exception {
  UserGroupInformation remoteUser=UserGroupInformation.createRemoteUser("String_Node_Str");
  remoteUser.doAs(new PrivilegedAction<Void>(){
    @Override public Void run(){
      try {
        deleteDatasetInstance(NamespaceId.SYSTEM.dataset("String_Node_Str"));
        Assert.fail();
      }
 catch (      DatasetManagementException e) {
        Assert.assertTrue(e.getMessage().contains("String_Node_Str"));
      }
catch (      Exception e) {
        Assert.fail("String_Node_Str");
      }
      return null;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * This test is to make sure we do not bypass the authorization check for datasets in system namespace
 */
@Test public void testDeleteSystemDatasets() throws Exception {
  UserGroupInformation remoteUser=UserGroupInformation.createRemoteUser("String_Node_Str");
  remoteUser.doAs(new PrivilegedAction<Void>(){
    @Override public Void run(){
      try {
        deleteDatasetInstance(NamespaceId.SYSTEM.dataset("String_Node_Str"));
        Assert.fail();
      }
 catch (      UnauthorizedException e) {
      }
catch (      Exception e) {
        Assert.fail("String_Node_Str");
      }
      return null;
    }
  }
);
}
Program: 4745
Project: 4745
Buggy source:
@Override public Void run(){
  try {
    deleteDatasetInstance(NamespaceId.SYSTEM.dataset("String_Node_Str"));
    Assert.fail();
  }
 catch (  DatasetManagementException e) {
    Assert.assertTrue(e.getMessage().contains("String_Node_Str"));
  }
catch (  Exception e) {
    Assert.fail("String_Node_Str");
  }
  return null;
}

Fixed version (ground truth):
@Override public Void run(){
  try {
    deleteDatasetInstance(NamespaceId.SYSTEM.dataset("String_Node_Str"));
    Assert.fail();
  }
 catch (  UnauthorizedException e) {
  }
catch (  Exception e) {
    Assert.fail("String_Node_Str");
  }
  return null;
}
Program: 4746
Project: 4746
Buggy source:
@After @Override public void afterTest() throws Exception {
  Authorizer authorizer=getAuthorizer();
  grantAndAssertSuccess(AUTH_NAMESPACE,SecurityRequestContext.toPrincipal(),EnumSet.of(Action.ADMIN));
  if (getNamespaceAdmin().exists(AUTH_NAMESPACE)) {
    getNamespaceAdmin().delete(AUTH_NAMESPACE);
    Assert.assertFalse(getNamespaceAdmin().exists(AUTH_NAMESPACE));
  }
  revokeAndAssertSuccess(AUTH_NAMESPACE);
  for (  EntityId entityId : cleanUpEntities) {
    revokeAndAssertSuccess(entityId);
  }
  Assert.assertEquals(Collections.emptySet(),authorizer.listPrivileges(ALICE));
}

Fixed version (ground truth):
@After @Override public void afterTest() throws Exception {
  Authorizer authorizer=getAuthorizer();
  SecurityRequestContext.setUserId(ALICE.getName());
  grantAndAssertSuccess(AUTH_NAMESPACE,SecurityRequestContext.toPrincipal(),EnumSet.of(Action.ADMIN));
  if (getNamespaceAdmin().exists(AUTH_NAMESPACE)) {
    getNamespaceAdmin().delete(AUTH_NAMESPACE);
    Assert.assertFalse(getNamespaceAdmin().exists(AUTH_NAMESPACE));
  }
  revokeAndAssertSuccess(AUTH_NAMESPACE);
  for (  EntityId entityId : cleanUpEntities) {
    revokeAndAssertSuccess(entityId);
  }
  Assert.assertEquals(Collections.emptySet(),authorizer.listPrivileges(ALICE));
}
Program: 4751
Project: 4751
Buggy source:
/** 
 * Adds a set of new metadata entries for a particular partition. If the metadata key already exists, it will be overwritten.
 * @throws PartitionNotFoundException when a partition for the given key is not found
 * @throws IllegalArgumentException if the partition key does not match the partitioning of the dataset
 */
void addMetadata(PartitionKey key,Map<String,String> metadata);

Fixed version (ground truth):
/** 
 * Adds a set of new metadata entries for a particular partition. Note that existing entries cannot be updated.
 * @throws DataSetException when an attempt is made to update existing entries
 * @throws PartitionNotFoundException when a partition for the given key is not found
 * @throws IllegalArgumentException if the partition key does not match the partitioning of the dataset
 */
void addMetadata(PartitionKey key,Map<String,String> metadata);
Program: 4752
Project: 4752
Buggy source:
/** 
 * Adds a set of new metadata entries for a particular partition If the metadata key already exists, it will be overwritten.
 * @param time the partition time in milliseconds since the Epoch
 * @throws PartitionNotFoundException when a partition for the given time is not found
 */
void addMetadata(long time,Map<String,String> metadata);

Fixed version (ground truth):
/** 
 * Adds a set of new metadata entries for a particular partition Note that existing entries can not be updated.
 * @param time the partition time in milliseconds since the Epoch
 * @throws DataSetException in case an attempt is made to update existing entries.
 */
void addMetadata(long time,Map<String,String> metadata);
Program: 4753
Project: 4753
Buggy source:
private void addMetadataToPut(Map<String,String> metadata,Put put){
  for (  Map.Entry<String,String> entry : metadata.entrySet()) {
    byte[] columnKey=columnKeyFromMetadataKey(entry.getKey());
    put.add(columnKey,Bytes.toBytes(entry.getValue()));
  }
}

Fixed version (ground truth):
private void addMetadataToPut(Row existingRow,Map<String,String> metadata,Put put,boolean allowUpdates){
  if (!allowUpdates) {
    checkMetadataDoesNotExist(existingRow,metadata);
  }
  for (  Map.Entry<String,String> entry : metadata.entrySet()) {
    byte[] columnKey=columnKeyFromMetadataKey(entry.getKey());
    put.add(columnKey,Bytes.toBytes(entry.getValue()));
  }
}
Program: 4754
Project: 4754
Buggy source:
@WriteOnly @Override public void addMetadata(PartitionKey key,Map<String,String> metadata){
  final byte[] rowKey=generateRowKey(key,partitioning);
  Row row=partitionsTable.get(rowKey);
  if (row.isEmpty()) {
    throw new PartitionNotFoundException(key,getName());
  }
  Put put=new Put(rowKey);
  addMetadataToPut(metadata,put);
  partitionsTable.put(put);
}

Fixed version (ground truth):
@WriteOnly @Override public void addMetadata(PartitionKey key,Map<String,String> metadata){
  setMetadata(key,metadata,false);
}
Program: 4758
Project: 4758
Buggy source:
/** 
 * Drops all datasets in the given namespace. If authorization is turned on, only datasets that the current principal that has   {@link Action#ADMIN} privilege will be deleted
 * @param namespaceId namespace to operate on
 * @throws Exception if it fails to delete dataset
 * @return the set of {@link DatasetId} that get deleted
 */
void dropAll(NamespaceId namespaceId) throws Exception {
  ensureNamespaceExists(namespaceId);
  Principal principal=authenticationContext.getPrincipal();
  Map<DatasetId,DatasetSpecification> datasets=new HashMap<>();
  for (  DatasetSpecification spec : instanceManager.getAll(namespaceId)) {
    DatasetId datasetId=namespaceId.dataset(spec.getName());
    if (!DatasetsUtil.isSystemDatasetInUserNamespace(datasetId)) {
      authorizationEnforcer.enforce(datasetId,principal,Action.ADMIN);
    }
    datasets.put(datasetId,spec);
  }
  for (  DatasetId datasetId : datasets.keySet()) {
    dropDataset(datasetId,datasets.get(datasetId));
  }
}

Fixed version (ground truth):
/** 
 * Drops all datasets in the given namespace. If authorization is turned on, only datasets that the current principal that has   {@link Action#ADMIN} privilege will be deleted
 * @param namespaceId namespace to operate on
 * @throws Exception if it fails to delete dataset
 */
void dropAll(NamespaceId namespaceId) throws Exception {
  ensureNamespaceExists(namespaceId);
  Principal principal=authenticationContext.getPrincipal();
  Map<DatasetId,DatasetSpecification> datasets=new HashMap<>();
  for (  DatasetSpecification spec : instanceManager.getAll(namespaceId)) {
    DatasetId datasetId=namespaceId.dataset(spec.getName());
    if (!DatasetsUtil.isSystemDatasetInUserNamespace(datasetId)) {
      authorizationEnforcer.enforce(datasetId,principal,Action.ADMIN);
    }
    datasets.put(datasetId,spec);
  }
  for (  DatasetId datasetId : datasets.keySet()) {
    dropDataset(datasetId,datasets.get(datasetId));
  }
}
Program: 4759
Project: 4759
Buggy source:
/** 
 * Finds the   {@link DatasetTypeMeta} for the specified dataset type name.Search order - first in the specified namespace, then in the 'system' namespace from defaultModules
 * @param namespaceId {@link NamespaceId} for the specified namespace
 * @param typeName the name of the dataset type to search
 * @param byPassCheck a flag which determines whether to check privilege for the dataset type
 * @return {@link DatasetTypeMeta} for the type if found in either the specified namespace or in the system namespace,null otherwise. TODO: This may need to move to a util class eventually
 */
@Nullable private DatasetTypeMeta getTypeInfo(NamespaceId namespaceId,String typeName,boolean byPassCheck) throws Exception {
  DatasetTypeId datasetTypeId=ConversionHelpers.toDatasetTypeId(namespaceId,typeName);
  try {
    return byPassCheck ? noAuthDatasetTypeService.getType(datasetTypeId) : authorizationDatasetTypeService.getType(datasetTypeId);
  }
 catch (  DatasetTypeNotFoundException e) {
    try {
      DatasetTypeId systemDatasetTypeId=ConversionHelpers.toDatasetTypeId(NamespaceId.SYSTEM,typeName);
      return noAuthDatasetTypeService.getType(systemDatasetTypeId);
    }
 catch (    DatasetTypeNotFoundException exnWithSystemNS) {
      throw e;
    }
  }
}

Fixed version (ground truth):
/** 
 * Finds the   {@link DatasetTypeMeta} for the specified dataset type name.Search order - first in the specified namespace, then in the 'system' namespace from defaultModules
 * @param namespaceId {@link NamespaceId} for the specified namespace
 * @param typeName the name of the dataset type to search
 * @param byPassCheck a flag which determines whether to check privilege for the dataset type
 * @return {@link DatasetTypeMeta} for the type if found in either the specified namespace or in the system namespace,null otherwise. TODO: This may need to move to a util class eventually
 */
@Nullable private DatasetTypeMeta getTypeInfo(NamespaceId namespaceId,String typeName,boolean byPassCheck) throws Exception {
  DatasetTypeId datasetTypeId=ConversionHelpers.toDatasetTypeId(namespaceId,typeName);
  try {
    return byPassCheck ? noAuthDatasetTypeService.getType(datasetTypeId) : authorizationDatasetTypeService.getType(datasetTypeId);
  }
 catch (  DatasetTypeNotFoundException|UnauthorizedException e) {
    try {
      DatasetTypeId systemDatasetTypeId=ConversionHelpers.toDatasetTypeId(NamespaceId.SYSTEM,typeName);
      return noAuthDatasetTypeService.getType(systemDatasetTypeId);
    }
 catch (    DatasetTypeNotFoundException exnWithSystemNS) {
      throw e;
    }
  }
}
Program: 4761
Project: 4761
Buggy source:
@Inject TokenSecureStoreRenewer(YarnConfiguration hConf,CConfiguration cConf,LocationFactory locationFactory,SecureStore secureStore){
  this.hConf=hConf;
  this.locationFactory=locationFactory;
  this.secureStore=secureStore;
  this.secureExplore=cConf.getBoolean(Constants.Explore.EXPLORE_ENABLED) && UserGroupInformation.isSecurityEnabled();
}

Fixed version (ground truth):
@Inject TokenSecureStoreRenewer(YarnConfiguration yarnConf,CConfiguration cConf,LocationFactory locationFactory,SecureStore secureStore){
  this.yarnConf=yarnConf;
  this.locationFactory=locationFactory;
  this.secureStore=secureStore;
  this.secureExplore=cConf.getBoolean(Constants.Explore.EXPLORE_ENABLED) && UserGroupInformation.isSecurityEnabled();
}
Program: 4762
Project: 4762
Buggy source:
/** 
 * Creates a   {@link Credentials} that contains delegation tokens of the current user for all services that CDAP uses.
 */
public Credentials createCredentials(){
  try {
    Credentials refreshedCredentials=new Credentials();
    if (User.isSecurityEnabled()) {
      YarnTokenUtils.obtainToken(hConf,refreshedCredentials);
    }
    if (User.isHBaseSecurityEnabled(hConf)) {
      HBaseTokenUtils.obtainToken(hConf,refreshedCredentials);
    }
    if (secureExplore) {
      HiveTokenUtils.obtainToken(refreshedCredentials);
      JobHistoryServerTokenUtils.obtainToken(hConf,refreshedCredentials);
    }
    if (secureStore instanceof DelegationTokensUpdater) {
      String renewer=UserGroupInformation.getCurrentUser().getShortUserName();
      ((DelegationTokensUpdater)secureStore).addDelegationTokens(renewer,refreshedCredentials);
    }
    YarnUtils.addDelegationTokens(hConf,locationFactory,refreshedCredentials);
    return refreshedCredentials;
  }
 catch (  IOException ioe) {
    throw Throwables.propagate(ioe);
  }
}

Fixed version (ground truth):
/** 
 * Creates a   {@link Credentials} that contains delegation tokens of the current user for all services that CDAP uses.
 */
public Credentials createCredentials(){
  try {
    Credentials refreshedCredentials=new Credentials();
    if (User.isSecurityEnabled()) {
      YarnTokenUtils.obtainToken(yarnConf,refreshedCredentials);
    }
    if (User.isHBaseSecurityEnabled(yarnConf)) {
      HBaseTokenUtils.obtainToken(yarnConf,refreshedCredentials);
    }
    if (secureExplore) {
      HiveTokenUtils.obtainToken(refreshedCredentials);
      JobHistoryServerTokenUtils.obtainToken(yarnConf,refreshedCredentials);
    }
    if (secureStore instanceof DelegationTokensUpdater) {
      String renewer=UserGroupInformation.getCurrentUser().getShortUserName();
      ((DelegationTokensUpdater)secureStore).addDelegationTokens(renewer,refreshedCredentials);
    }
    YarnUtils.addDelegationTokens(yarnConf,locationFactory,refreshedCredentials);
    return refreshedCredentials;
  }
 catch (  IOException ioe) {
    throw Throwables.propagate(ioe);
  }
}
Program: 4763
Project: 4763
Buggy source:
private long calculateUpdateInterval(){
  List<Long> renewalTimes=Lists.newArrayList();
  renewalTimes.add(hConf.getLong(DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY,DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT));
  renewalTimes.add(hConf.getLong(Constants.HBase.AUTH_KEY_UPDATE_INTERVAL,TimeUnit.MILLISECONDS.convert(1,TimeUnit.DAYS)));
  if (secureExplore) {
    renewalTimes.add(hConf.getLong(YarnConfiguration.DELEGATION_TOKEN_RENEW_INTERVAL_KEY,YarnConfiguration.DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT));
    Configuration hiveConf=getHiveConf();
    if (hiveConf != null) {
      renewalTimes.add(hiveConf.getLong("String_Node_Str",TimeUnit.MILLISECONDS.convert(1,TimeUnit.DAYS)));
    }
 else {
      renewalTimes.add(TimeUnit.MILLISECONDS.convert(1,TimeUnit.DAYS));
    }
    renewalTimes.add(hConf.getLong(MRConfig.DELEGATION_TOKEN_RENEW_INTERVAL_KEY,MRConfig.DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT));
  }
  Long minimumInterval=Collections.min(renewalTimes);
  long delay=minimumInterval - TimeUnit.HOURS.toMillis(1);
  if (delay <= 0) {
    delay=(minimumInterval <= 2) ? 1 : minimumInterval / 2;
  }
  LOG.info("String_Node_Str",delay);
  return delay;
}

Fixed version (ground truth):
private long calculateUpdateInterval(){
  List<Long> renewalTimes=Lists.newArrayList();
  renewalTimes.add(yarnConf.getLong(DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY,DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT));
  renewalTimes.add(yarnConf.getLong(Constants.HBase.AUTH_KEY_UPDATE_INTERVAL,TimeUnit.MILLISECONDS.convert(1,TimeUnit.DAYS)));
  if (yarnConf.getBoolean(Constants.Explore.TIMELINE_SERVICE_ENABLED,false)) {
    renewalTimes.add(yarnConf.getLong(Constants.Explore.TIMELINE_DELEGATION_KEY_UPDATE_INTERVAL,TimeUnit.MILLISECONDS.convert(1,TimeUnit.DAYS)));
  }
  if (secureExplore) {
    renewalTimes.add(yarnConf.getLong(YarnConfiguration.DELEGATION_TOKEN_RENEW_INTERVAL_KEY,YarnConfiguration.DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT));
    Configuration hiveConf=getHiveConf();
    if (hiveConf != null) {
      renewalTimes.add(hiveConf.getLong("String_Node_Str",TimeUnit.MILLISECONDS.convert(1,TimeUnit.DAYS)));
    }
 else {
      renewalTimes.add(TimeUnit.MILLISECONDS.convert(1,TimeUnit.DAYS));
    }
    renewalTimes.add(yarnConf.getLong(MRConfig.DELEGATION_TOKEN_RENEW_INTERVAL_KEY,MRConfig.DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT));
  }
  Long minimumInterval=Collections.min(renewalTimes);
  long delay=minimumInterval - TimeUnit.HOURS.toMillis(1);
  if (delay <= 0) {
    delay=(minimumInterval <= 2) ? 1 : minimumInterval / 2;
  }
  LOG.info("String_Node_Str",delay);
  return delay;
}
Program: 4765
Project: 4765
Buggy source:
@Override public void prepareForDeferredProcessing(){
  loggingEvent.prepareForDeferredProcessing();
}

Fixed version (ground truth):
@Override public void prepareForDeferredProcessing(){
  loggingEvent.prepareForDeferredProcessing();
  Object[] args=loggingEvent.getArgumentArray();
  if (args != null && argumentArray == null) {
    argumentArray=new Object[args.length];
    for (int i=0; i < args.length; i++) {
      argumentArray[i]=args[i].toString();
    }
  }
}
Program: 4766
Project: 4766
Buggy source:
@Override public Object[] getArgumentArray(){
  return loggingEvent.getArgumentArray();
}

Fixed version (ground truth):
@Override public Object[] getArgumentArray(){
  return argumentArray == null ? loggingEvent.getArgumentArray() : argumentArray;
}
Program: 4767
Project: 4767
Buggy source:
/** 
 * Encodes a   {@link ILoggingEvent} to byte array.
 */
public byte[] toBytes(ILoggingEvent event){
  event.prepareForDeferredProcessing();
  ByteArrayOutputStream out=new ByteArrayOutputStream();
  BinaryEncoder encoder=EncoderFactory.get().directBinaryEncoder(out,null);
  GenericDatumWriter<GenericRecord> writer=new GenericDatumWriter<>(getAvroSchema());
  try {
    writer.write(toGenericRecord(event),encoder);
  }
 catch (  IOException e) {
    throw Throwables.propagate(e);
  }
  return out.toByteArray();
}

Fixed version (ground truth):
/** 
 * Encodes a   {@link ILoggingEvent} to byte array.
 */
public byte[] toBytes(ILoggingEvent event){
  ByteArrayOutputStream out=new ByteArrayOutputStream();
  BinaryEncoder encoder=EncoderFactory.get().directBinaryEncoder(out,null);
  GenericDatumWriter<GenericRecord> writer=new GenericDatumWriter<>(getAvroSchema());
  try {
    writer.write(toGenericRecord(event),encoder);
  }
 catch (  IOException e) {
    throw Throwables.propagate(e);
  }
  return out.toByteArray();
}
Program: 4768
Project: 4768
Buggy source:
@BeforeClass public static void setup() throws Exception {
  SConfiguration sConf=SConfiguration.create();
  sConf.set(Constants.Security.Store.FILE_PASSWORD,"String_Node_Str");
  CConfiguration cConf=createCConf();
  final Injector injector=AppFabricTestHelper.getInjector(cConf,sConf,new AbstractModule(){
    @Override protected void configure(){
    }
  }
);
  discoveryServiceClient=injector.getInstance(DiscoveryServiceClient.class);
  appFabricServer=injector.getInstance(AppFabricServer.class);
  appFabricServer.startAndWait();
  waitForService(Constants.Service.DATASET_MANAGER);
  secureStore=injector.getInstance(SecureStore.class);
  secureStoreManager=injector.getInstance(SecureStoreManager.class);
  authorizer=injector.getInstance(AuthorizerInstantiator.class).get();
  String user=SecurityUtil.getMasterPrincipal(cConf);
  authorizer.grant(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
  injector.getInstance(NamespaceAdmin.class).create(NamespaceMeta.DEFAULT);
  authorizer.revoke(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
}

Fixed version (ground truth):
@BeforeClass public static void setup() throws Exception {
  SConfiguration sConf=SConfiguration.create();
  sConf.set(Constants.Security.Store.FILE_PASSWORD,"String_Node_Str");
  CConfiguration cConf=createCConf();
  final Injector injector=AppFabricTestHelper.getInjector(cConf,sConf,new AbstractModule(){
    @Override protected void configure(){
    }
  }
);
  discoveryServiceClient=injector.getInstance(DiscoveryServiceClient.class);
  appFabricServer=injector.getInstance(AppFabricServer.class);
  appFabricServer.startAndWait();
  waitForService(Constants.Service.DATASET_MANAGER);
  secureStore=injector.getInstance(SecureStore.class);
  secureStoreManager=injector.getInstance(SecureStoreManager.class);
  authorizer=injector.getInstance(AuthorizerInstantiator.class).get();
  String user=SecurityUtil.getMasterPrincipal(cConf);
  authorizer.grant(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
  NamespaceAdmin namespaceAdmin=injector.getInstance(NamespaceAdmin.class);
  if (!namespaceAdmin.exists(NamespaceId.DEFAULT)) {
    namespaceAdmin.create(NamespaceMeta.DEFAULT);
  }
  authorizer.revoke(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
}
Program: 4769
Project: 4769
Buggy source:
@BeforeClass public static void setup() throws Exception {
  cConf=createCConf();
  Injector injector=AppFabricTestHelper.getInjector(cConf);
  authorizer=injector.getInstance(AuthorizerInstantiator.class).get();
  appFabricServer=injector.getInstance(AppFabricServer.class);
  appFabricServer.startAndWait();
  programLifecycleService=injector.getInstance(ProgramLifecycleService.class);
  String user=SecurityUtil.getMasterPrincipal(cConf);
  authorizer.grant(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
  injector.getInstance(NamespaceAdmin.class).create(NamespaceMeta.DEFAULT);
  authorizer.revoke(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
}

Fixed version (ground truth):
@BeforeClass public static void setup() throws Exception {
  cConf=createCConf();
  Injector injector=AppFabricTestHelper.getInjector(cConf);
  authorizer=injector.getInstance(AuthorizerInstantiator.class).get();
  appFabricServer=injector.getInstance(AppFabricServer.class);
  appFabricServer.startAndWait();
  programLifecycleService=injector.getInstance(ProgramLifecycleService.class);
  String user=SecurityUtil.getMasterPrincipal(cConf);
  authorizer.grant(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
  NamespaceAdmin namespaceAdmin=injector.getInstance(NamespaceAdmin.class);
  if (!namespaceAdmin.exists(NamespaceId.DEFAULT)) {
    namespaceAdmin.create(NamespaceMeta.DEFAULT);
  }
  authorizer.revoke(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
}
Program: 4770
Project: 4770
Buggy source:
@BeforeClass public static void setup() throws Exception {
  cConf=createCConf();
  final Injector injector=AppFabricTestHelper.getInjector(cConf);
  metadataAdmin=injector.getInstance(MetadataAdmin.class);
  authorizer=injector.getInstance(AuthorizerInstantiator.class).get();
  appFabricServer=injector.getInstance(AppFabricServer.class);
  appFabricServer.startAndWait();
  String user=SecurityUtil.getMasterPrincipal(cConf);
  authorizer.grant(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
  injector.getInstance(NamespaceAdmin.class).create(NamespaceMeta.DEFAULT);
  authorizer.revoke(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
}

Fixed version (ground truth):
@BeforeClass public static void setup() throws Exception {
  cConf=createCConf();
  final Injector injector=AppFabricTestHelper.getInjector(cConf);
  metadataAdmin=injector.getInstance(MetadataAdmin.class);
  authorizer=injector.getInstance(AuthorizerInstantiator.class).get();
  appFabricServer=injector.getInstance(AppFabricServer.class);
  appFabricServer.startAndWait();
  String user=SecurityUtil.getMasterPrincipal(cConf);
  authorizer.grant(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
  NamespaceAdmin namespaceAdmin=injector.getInstance(NamespaceAdmin.class);
  if (!namespaceAdmin.exists(NamespaceId.DEFAULT)) {
    namespaceAdmin.create(NamespaceMeta.DEFAULT);
  }
  authorizer.revoke(NamespaceId.DEFAULT,new Principal(user,Principal.PrincipalType.USER),Collections.singleton(Action.ADMIN));
}
Program: 4771
Project: 4771
Buggy source:
@Inject public TransactionHttpHandler(CConfiguration cConf,TransactionSystemClient txClient){
  this.cConf=cConf;
  this.txClient=new TransactionSystemClientAdapter(txClient);
  this.pruneEnable=cConf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE,TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE);
}

Fixed version (ground truth):
@Inject public TransactionHttpHandler(Configuration hConf,CConfiguration cConf,TransactionSystemClient txClient){
  this.hConf=hConf;
  this.cConf=cConf;
  this.txClient=new TransactionSystemClientAdapter(txClient);
  this.pruneEnable=cConf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE,TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE);
}
Program: 4772
Project: 4772
Buggy source:
private boolean initializePruningDebug(HttpResponder responder){
  if (!pruneEnable) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
    return false;
  }
synchronized (this) {
    if (debugClazz == null || debugObject == null) {
      try {
        this.debugClazz=getClass().getClassLoader().loadClass("String_Node_Str");
        this.debugObject=debugClazz.newInstance();
        Configuration hConf=new Configuration();
        for (        Map.Entry<String,String> entry : cConf) {
          hConf.set(entry.getKey(),entry.getValue());
        }
        Method initMethod=debugClazz.getMethod("String_Node_Str",Configuration.class);
        initMethod.setAccessible(true);
        initMethod.invoke(debugObject,hConf);
      }
 catch (      ClassNotFoundException|IllegalAccessException|InstantiationException ex) {
        LOG.debug("String_Node_Str",ex);
        this.debugClazz=null;
      }
catch (      NoSuchMethodException|InvocationTargetException ex) {
        LOG.debug("String_Node_Str",ex);
        this.debugClazz=null;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean initializePruningDebug(HttpResponder responder){
  if (!pruneEnable) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
    return false;
  }
synchronized (this) {
    if (debugClazz == null || debugObject == null) {
      try {
        this.debugClazz=getClass().getClassLoader().loadClass("String_Node_Str");
        this.debugObject=debugClazz.newInstance();
        for (        Map.Entry<String,String> entry : cConf) {
          hConf.set(entry.getKey(),entry.getValue());
        }
        Method initMethod=debugClazz.getMethod("String_Node_Str",Configuration.class);
        initMethod.setAccessible(true);
        initMethod.invoke(debugObject,hConf);
      }
 catch (      ClassNotFoundException|IllegalAccessException|InstantiationException ex) {
        LOG.debug("String_Node_Str",ex);
        this.debugClazz=null;
      }
catch (      NoSuchMethodException|InvocationTargetException ex) {
        LOG.debug("String_Node_Str",ex);
        this.debugClazz=null;
      }
    }
  }
  return true;
}
Program: 4773
Project: 4773
Buggy source:
@Path("String_Node_Str") @GET public void getRegionsToBeCompacted(HttpRequest request,HttpResponder responder){
  if (!initializePruningDebug(responder)) {
    return;
  }
  try {
    Method method=debugClazz.getMethod("String_Node_Str");
    method.setAccessible(true);
    Object response=method.invoke(debugObject);
    Set<String> regionNames=(Set<String>)response;
    responder.sendJson(HttpResponseStatus.OK,regionNames);
  }
 catch (  Exception e) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,e.getMessage());
    LOG.debug("String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Path("String_Node_Str") @GET public void getRegionsToBeCompacted(HttpRequest request,HttpResponder responder,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") int numRegions){
  if (!initializePruningDebug(responder)) {
    return;
  }
  try {
    Method method=debugClazz.getMethod("String_Node_Str",Integer.class);
    method.setAccessible(true);
    Object response=method.invoke(debugObject,numRegions);
    Set<String> regionNames=(Set<String>)response;
    responder.sendJson(HttpResponseStatus.OK,regionNames);
  }
 catch (  Exception e) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,e.getMessage());
    LOG.debug("String_Node_Str",e);
  }
}
Program: 4774
Project: 4774
Buggy source:
public static synchronized Injector getInjector(CConfiguration conf,@Nullable SConfiguration sConf,Module overrides){
  if (injector == null) {
    configuration=conf;
    configuration.set(Constants.CFG_LOCAL_DATA_DIR,TEMP_FOLDER.newFolder("String_Node_Str").getAbsolutePath());
    configuration.set(Constants.AppFabric.REST_PORT,Integer.toString(Networks.getRandomPort()));
    configuration.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET,true);
    injector=Guice.createInjector(Modules.override(new AppFabricTestModule(configuration,sConf)).with(overrides));
    if (configuration.getBoolean(Constants.Security.ENABLED) && configuration.getBoolean(Constants.Security.Authorization.ENABLED)) {
      injector.getInstance(AuthorizationBootstrapper.class).run();
    }
    MessagingService messagingService=injector.getInstance(MessagingService.class);
    if (messagingService instanceof Service) {
      ((Service)messagingService).startAndWait();
    }
    injector.getInstance(TransactionManager.class).startAndWait();
    injector.getInstance(DatasetOpExecutor.class).startAndWait();
    injector.getInstance(DatasetService.class).startAndWait();
    injector.getInstance(StreamCoordinatorClient.class).startAndWait();
    injector.getInstance(NotificationService.class).startAndWait();
    injector.getInstance(MetricsCollectionService.class).startAndWait();
    Scheduler programScheduler=injector.getInstance(Scheduler.class);
    if (programScheduler instanceof Service) {
      ((Service)programScheduler).startAndWait();
    }
  }
  return injector;
}

Fixed version (ground truth):
public static synchronized Injector getInjector(CConfiguration conf,@Nullable SConfiguration sConf,Module overrides){
  if (injector == null) {
    configuration=conf;
    configuration.set(Constants.CFG_LOCAL_DATA_DIR,TEMP_FOLDER.newFolder("String_Node_Str").getAbsolutePath());
    configuration.set(Constants.AppFabric.REST_PORT,Integer.toString(Networks.getRandomPort()));
    configuration.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET,true);
    injector=Guice.createInjector(Modules.override(new AppFabricTestModule(configuration,sConf)).with(overrides));
    if (configuration.getBoolean(Constants.Security.ENABLED) && configuration.getBoolean(Constants.Security.Authorization.ENABLED)) {
    }
    MessagingService messagingService=injector.getInstance(MessagingService.class);
    if (messagingService instanceof Service) {
      ((Service)messagingService).startAndWait();
    }
    injector.getInstance(TransactionManager.class).startAndWait();
    injector.getInstance(DatasetOpExecutor.class).startAndWait();
    injector.getInstance(DatasetService.class).startAndWait();
    injector.getInstance(StreamCoordinatorClient.class).startAndWait();
    injector.getInstance(NotificationService.class).startAndWait();
    injector.getInstance(MetricsCollectionService.class).startAndWait();
    Scheduler programScheduler=injector.getInstance(Scheduler.class);
    if (programScheduler instanceof Service) {
      ((Service)programScheduler).startAndWait();
    }
  }
  return injector;
}