nus-yam/ex-repair huggingface dataset:
Program: 5010
Project: 5010
Buggy source:
@Override public FactTable getOrCreateFactTable(int resolution){
  String tableName=cConf.get(Constants.Metrics.METRICS_TABLE_PREFIX,Constants.Metrics.DEFAULT_METRIC_TABLE_PREFIX) + "String_Node_Str" + resolution;
  int ttl=cConf.getInt(Constants.Metrics.RETENTION_SECONDS + "String_Node_Str" + resolution+ "String_Node_Str",-1);
  TableProperties.Builder props=TableProperties.builder();
  if (ttl > 0 && resolution != Integer.MAX_VALUE) {
    props.setTTL(ttl);
  }
  props.setReadlessIncrementSupport(true);
  props.add(HBaseTableAdmin.PROPERTY_SPLITS,GSON.toJson(FactTable.getSplits(DefaultMetricStore.AGGREGATIONS.size())));
  MetricsTable table=getOrCreateMetricsTable(tableName,props.build());
  LOG.debug("String_Node_Str",tableName);
  return new FactTable(table,entityTable.get(),resolution,getRollTime(resolution));
}

Fixed version (ground truth):
@Override public FactTable getOrCreateFactTable(int resolution){
  String tableName=cConf.get(Constants.Metrics.METRICS_TABLE_PREFIX,Constants.Metrics.DEFAULT_METRIC_TABLE_PREFIX) + "String_Node_Str" + resolution;
  int ttl=cConf.getInt(Constants.Metrics.RETENTION_SECONDS + "String_Node_Str" + resolution+ "String_Node_Str",-1);
  TableProperties.Builder props=TableProperties.builder();
  if (ttl > 0 && resolution != Integer.MAX_VALUE) {
    props.setTTL(ttl);
  }
  props.setReadlessIncrementSupport(true);
  props.add(HBaseTableAdmin.PROPERTY_SPLITS,GSON.toJson(FactTable.getSplits(DefaultMetricStore.AGGREGATIONS.size())));
  MetricsTable table=getOrCreateMetricsTable(tableName,props.build());
  return new FactTable(table,entityTable.get(),resolution,getRollTime(resolution));
}
Program: 5011
Project: 5011
Buggy source:
@Override public MetricsConsumerMetaTable createConsumerMeta(){
  String tableName=cConf.get(Constants.Metrics.KAFKA_META_TABLE);
  MetricsTable table=getOrCreateMetricsTable(tableName,DatasetProperties.EMPTY);
  LOG.debug("String_Node_Str",tableName);
  return new MetricsConsumerMetaTable(table);
}

Fixed version (ground truth):
@Override public MetricsConsumerMetaTable createConsumerMeta(){
  String tableName=cConf.get(Constants.Metrics.KAFKA_META_TABLE);
  MetricsTable table=getOrCreateMetricsTable(tableName,DatasetProperties.EMPTY);
  return new MetricsConsumerMetaTable(table);
}
Program: 5012
Project: 5012
Buggy source:
@Override public void destroy(){
  WorkflowContext workflowContext=getContext();
  if (!workflowContext.getDataTracer(PostAction.PLUGIN_TYPE).isEnabled()) {
    BasicArguments arguments=new BasicArguments(workflowContext.getToken(),workflowContext.getRuntimeArguments());
    for (    Map.Entry<String,PostAction> endingActionEntry : postActions.entrySet()) {
      String name=endingActionEntry.getKey();
      PostAction action=endingActionEntry.getValue();
      StageInfo stageInfo=StageInfo.builder(name,PostAction.PLUGIN_TYPE).setStageLoggingEnabled(spec.isStageLoggingEnabled()).setProcessTimingEnabled(spec.isProcessTimingEnabled()).build();
      BatchActionContext context=new WorkflowBackedActionContext(workflowContext,workflowMetrics,stageInfo,arguments);
      try {
        action.run(context);
      }
 catch (      Throwable t) {
        LOG.error("String_Node_Str",name,t);
      }
    }
  }
  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):
@Override public void destroy(){
  WorkflowContext workflowContext=getContext();
  if (!workflowContext.getDataTracer(PostAction.PLUGIN_TYPE).isEnabled()) {
    BasicArguments arguments=new BasicArguments(workflowContext.getToken(),workflowContext.getRuntimeArguments());
    for (    Map.Entry<String,PostAction> endingActionEntry : postActions.entrySet()) {
      String name=endingActionEntry.getKey();
      PostAction action=endingActionEntry.getValue();
      StageInfo stageInfo=StageInfo.builder(name,PostAction.PLUGIN_TYPE).setStageLoggingEnabled(spec.isStageLoggingEnabled()).setProcessTimingEnabled(spec.isProcessTimingEnabled()).build();
      BatchActionContext context=new WorkflowBackedActionContext(workflowContext,workflowMetrics,stageInfo,arguments);
      try {
        action.run(context);
      }
 catch (      Throwable t) {
        LOG.error("String_Node_Str",name,t);
      }
    }
  }
  ProgramStatus status=getContext().getState().getStatus();
  if (status == ProgramStatus.FAILED) {
    WRAPPERLOGGER.error("String_Node_Str",getContext().getApplicationSpecification().getName());
  }
 else {
    WRAPPERLOGGER.info("String_Node_Str",getContext().getApplicationSpecification().getName(),status == ProgramStatus.COMPLETED ? "String_Node_Str" : status.name().toLowerCase());
  }
}
Program: 5013
Project: 5013
Buggy source:
public void process(KeyValue<String,Object> value){
  try {
    if (removeStageName) {
      transformation.transform(value.getValue(),emitter);
    }
 else {
      transformation.transform(value,emitter);
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void process(KeyValue<String,Object> value){
  try {
    if (removeStageName) {
      transformation.transform(value.getValue(),emitter);
    }
 else {
      transformation.transform(value,emitter);
    }
  }
 catch (  StageFailureException e) {
    throw e;
  }
catch (  Exception e) {
    Throwable rootCause=Throwables.getRootCause(e);
    throw new StageFailureException(String.format("String_Node_Str" + "String_Node_Str",stageName,rootCause.getMessage()),rootCause);
  }
}
Program: 5014
Project: 5014
Buggy source:
@Override protected void reduce(Object key,Iterable values,Context context) throws IOException, InterruptedException {
  try {
    transformRunner.transform(key,values.iterator());
  }
 catch (  Exception e) {
    Throwables.propagate(e);
  }
}

Fixed version (ground truth):
@Override protected void reduce(Object key,Iterable values,Context context) throws IOException, InterruptedException {
  try {
    transformRunner.transform(key,values.iterator());
  }
 catch (  StageFailureException e) {
    PIPELINE_LOG.error("String_Node_Str",e.getMessage(),e.getCause());
    Throwables.propagate(e.getCause());
  }
catch (  Exception e) {
    Throwables.propagate(e);
  }
}
Program: 5015
Project: 5015
Buggy source:
@Override public void map(Object key,Object value,Mapper.Context context) throws IOException, InterruptedException {
  try {
    transformRunner.transform(key,value);
  }
 catch (  Exception e) {
    Throwables.propagate(e);
  }
}

Fixed version (ground truth):
@Override public void map(Object key,Object value,Mapper.Context context) throws IOException, InterruptedException {
  try {
    transformRunner.transform(key,value);
  }
 catch (  StageFailureException e) {
    PIPELINE_LOG.error("String_Node_Str",e.getMessage(),e.getCause());
    Throwables.propagate(e.getCause());
  }
catch (  Exception e) {
    Throwables.propagate(e);
  }
}
Program: 5016
Project: 5016
Buggy source:
public void runOneIteration(IN input) throws Exception {
  for (  String stageName : startingPoints) {
    PipeTransformDetail transformDetail=transformDetailMap.get(stageName);
    try {
      transformDetail.process(new KeyValue<String,Object>(stageName,input));
    }
 catch (    Exception e) {
      PIPELINE_LOG.error("String_Node_Str" + "String_Node_Str",stageName,Throwables.getRootCause(e).getMessage(),Throwables.getRootCause(e));
      throw e;
    }
  }
}

Fixed version (ground truth):
public void runOneIteration(IN input){
  for (  String stageName : startingPoints) {
    PipeTransformDetail transformDetail=transformDetailMap.get(stageName);
    transformDetail.process(new KeyValue<String,Object>(stageName,input));
  }
}
Program: 5018
Project: 5018
Buggy source:
@Override public void create(NamespaceMeta namespaceMeta) throws IOException, ExploreException, SQLException {
  super.create(namespaceMeta);
  if (NamespaceId.DEFAULT.equals(namespaceMeta.getNamespaceId())) {
    return;
  }
  String hbaseNamespace=tableUtil.getHBaseNamespace(namespaceMeta);
  if (Strings.isNullOrEmpty(namespaceMeta.getConfig().getHbaseNamespace())) {
    try (HBaseDDLExecutor executor=hBaseDDLExecutorFactory.get()){
      boolean created=executor.createNamespaceIfNotExists(hbaseNamespace);
      if (namespaceMeta.getConfig().getGroupName() != null) {
        try {
          executor.grantPermissions(hbaseNamespace,null,ImmutableMap.of("String_Node_Str" + namespaceMeta.getConfig().getGroupName(),"String_Node_Str"));
        }
 catch (        IOException|RuntimeException e) {
          if (created) {
            try {
              executor.deleteNamespaceIfExists(hbaseNamespace);
            }
 catch (            Throwable t) {
              e.addSuppressed(t);
            }
          }
          throw e;
        }
      }
    }
 catch (    Throwable t) {
      try {
        super.delete(namespaceMeta.getNamespaceId());
      }
 catch (      Exception e) {
        t.addSuppressed(e);
      }
      throw t;
    }
  }
  try (HBaseAdmin admin=new HBaseAdmin(hConf)){
    if (!tableUtil.hasNamespace(admin,hbaseNamespace)) {
      throw new IOException(String.format("String_Node_Str",hbaseNamespace,namespaceMeta.getName()));
    }
  }
 }

Fixed version (ground truth):
@Override public void create(NamespaceMeta namespaceMeta) throws IOException, ExploreException, SQLException {
  super.create(namespaceMeta);
  if (NamespaceId.DEFAULT.equals(namespaceMeta.getNamespaceId())) {
    return;
  }
  String hbaseNamespace=tableUtil.getHBaseNamespace(namespaceMeta);
  if (Strings.isNullOrEmpty(namespaceMeta.getConfig().getHbaseNamespace())) {
    try (HBaseDDLExecutor executor=hBaseDDLExecutorFactory.get()){
      boolean created=executor.createNamespaceIfNotExists(hbaseNamespace);
      if (namespaceMeta.getConfig().getGroupName() != null) {
        try {
          executor.grantPermissions(hbaseNamespace,null,ImmutableMap.of("String_Node_Str" + namespaceMeta.getConfig().getGroupName(),"String_Node_Str"));
        }
 catch (        IOException|RuntimeException e) {
          if (created) {
            try {
              executor.deleteNamespaceIfExists(hbaseNamespace);
            }
 catch (            Throwable t) {
              e.addSuppressed(t);
            }
          }
          throw e;
        }
      }
    }
 catch (    Throwable t) {
      try {
        super.delete(namespaceMeta.getNamespaceId());
      }
 catch (      Exception e) {
        t.addSuppressed(e);
      }
      throw t;
    }
  }
  try (HBaseAdmin admin=new HBaseAdmin(hConf)){
    if (!tableUtil.hasNamespace(admin,hbaseNamespace)) {
      throw new IOException(String.format("String_Node_Str" + "String_Node_Str",hbaseNamespace,namespaceMeta.getName()));
    }
  }
 }
Program: 5019
Project: 5019
Buggy source:
@Override protected Entry computeNext(){
  if (closed || (!scanner.hasNext())) {
    return endOfData();
  }
  RawPayloadTableEntry entry=scanner.next();
  if (skipStartRow != null) {
    byte[] row=skipStartRow;
    skipStartRow=null;
    if (Bytes.equals(row,entry.getKey()) && !scanner.hasNext()) {
      return endOfData();
    }
    entry=scanner.next();
  }
  return new ImmutablePayloadTableEntry(entry.getKey(),entry.getValue());
}

Fixed version (ground truth):
@Override protected Entry computeNext(){
  if (closed || (!scanner.hasNext())) {
    return endOfData();
  }
  RawPayloadTableEntry entry=scanner.next();
  if (skipFirstRow) {
    skipFirstRow=false;
    if (!scanner.hasNext()) {
      return endOfData();
    }
    entry=scanner.next();
  }
  return new ImmutablePayloadTableEntry(entry.getKey(),entry.getValue());
}
Program: 5021
Project: 5021
Buggy source:
@Test public void testSingleMessage() throws Exception {
  TopicId topicId=NamespaceId.DEFAULT.topic("String_Node_Str");
  TopicMetadata metadata=new TopicMetadata(topicId,DEFAULT_PROPERTY);
  String payload="String_Node_Str";
  long txWritePtr=123L;
  try (MetadataTable metadataTable=getMetadataTable();PayloadTable table=getPayloadTable()){
    metadataTable.createTopic(metadata);
    List<PayloadTable.Entry> entryList=new ArrayList<>();
    entryList.add(new TestPayloadEntry(topicId,GENERATION,txWritePtr,0L,(short)0,Bytes.toBytes(payload)));
    table.store(entryList.iterator());
    byte[] messageId=new byte[MessageId.RAW_ID_SIZE];
    MessageId.putRawId(0L,(short)0,0L,(short)0,messageId,0);
    try (CloseableIterator<PayloadTable.Entry> iterator=table.fetch(metadata,txWritePtr,new MessageId(messageId),false,Integer.MAX_VALUE)){
      Assert.assertFalse(iterator.hasNext());
    }
     try (CloseableIterator<PayloadTable.Entry> iterator=table.fetch(metadata,txWritePtr,new MessageId(messageId),true,Integer.MAX_VALUE)){
      Assert.assertTrue(iterator.hasNext());
      PayloadTable.Entry entry=iterator.next();
      Assert.assertArrayEquals(Bytes.toBytes(payload),entry.getPayload());
      Assert.assertEquals(txWritePtr,entry.getTransactionWritePointer());
      Assert.assertFalse(iterator.hasNext());
    }
   }
 }

Fixed version (ground truth):
@Test public void testSingleMessage() throws Exception {
  TopicId topicId=NamespaceId.DEFAULT.topic("String_Node_Str");
  TopicMetadata metadata=new TopicMetadata(topicId,DEFAULT_PROPERTY);
  String payload="String_Node_Str";
  long txWritePtr=123L;
  try (MetadataTable metadataTable=getMetadataTable();PayloadTable table=getPayloadTable()){
    metadataTable.createTopic(metadata);
    List<PayloadTable.Entry> entryList=new ArrayList<>();
    entryList.add(new TestPayloadEntry(topicId,GENERATION,txWritePtr,1L,(short)1,Bytes.toBytes(payload)));
    table.store(entryList.iterator());
    byte[] messageId=new byte[MessageId.RAW_ID_SIZE];
    MessageId.putRawId(0L,(short)0,0L,(short)0,messageId,0);
    try (CloseableIterator<PayloadTable.Entry> iterator=table.fetch(metadata,txWritePtr,new MessageId(messageId),false,Integer.MAX_VALUE)){
      Assert.assertFalse(iterator.hasNext());
    }
     try (CloseableIterator<PayloadTable.Entry> iterator=table.fetch(metadata,txWritePtr,new MessageId(messageId),true,Integer.MAX_VALUE)){
      Assert.assertTrue(iterator.hasNext());
      PayloadTable.Entry entry=iterator.next();
      Assert.assertArrayEquals(Bytes.toBytes(payload),entry.getPayload());
      Assert.assertEquals(txWritePtr,entry.getTransactionWritePointer());
      Assert.assertFalse(iterator.hasNext());
    }
   }
 }
Program: 5022
Project: 5022
Buggy source:
/** 
 * Returns a singleton instance of the transaction state cache, performing lazy initialization if necessary.
 * @return A shared instance of the transaction state cache.
 */
@Override public TransactionStateCache get(){
  if (instance == null) {
synchronized (lock) {
      if (instance == null) {
        instance=new DefaultTransactionStateCache(sysConfigTablePrefix);
        instance.setConf(conf);
        instance.start();
      }
    }
  }
  return instance;
}

Fixed version (ground truth):
@Override public TransactionStateCache get(){
  TransactionStateCache cache=new DefaultTransactionStateCache(sysConfigTablePrefix);
  cache.setConf(conf);
  return cache;
}
Program: 5023
Project: 5023
Buggy source:
public DefaultTransactionStateCacheSupplier(String sysConfigTablePrefix,Configuration conf){
  super(conf);
  this.sysConfigTablePrefix=sysConfigTablePrefix;
}

Fixed version (ground truth):
public DefaultTransactionStateCacheSupplier(final String sysConfigTablePrefix,final Configuration conf){
  super(new Supplier<TransactionStateCache>(){
    @Override public TransactionStateCache get(){
      TransactionStateCache cache=new DefaultTransactionStateCache(sysConfigTablePrefix);
      cache.setConf(conf);
      return cache;
    }
  }
);
}
Program: 5024
Project: 5024
Buggy source:
@Override protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}

Fixed version (ground truth):
@Override protected CacheSupplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}
Program: 5025
Project: 5025
Buggy source:
@Override protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}

Fixed version (ground truth):
@Override protected CacheSupplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}
Program: 5026
Project: 5026
Buggy source:
@Override protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}

Fixed version (ground truth):
@Override protected CacheSupplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}
Program: 5027
Project: 5027
Buggy source:
@Override protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}

Fixed version (ground truth):
@Override protected CacheSupplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}
Program: 5028
Project: 5028
Buggy source:
@Override protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}

Fixed version (ground truth):
@Override protected CacheSupplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}
Program: 5029
Project: 5029
Buggy source:
@Override protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}

Fixed version (ground truth):
@Override protected CacheSupplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}
Program: 5030
Project: 5030
Buggy source:
@Override protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}

Fixed version (ground truth):
@Override protected CacheSupplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env){
  return new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix,env.getConfiguration());
}
Program: 5032
Project: 5032
Buggy source:
@POST @Path("String_Node_Str") public void listPrivileges(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  Principal principal=deserializeNext(arguments);
  LOG.trace("String_Node_Str",principal);
  Set<Privilege> privileges=authorizer.listPrivileges(principal);
  LOG.debug("String_Node_Str",principal,privileges,authorizer);
  responder.sendJson(HttpResponseStatus.OK,privileges);
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void listPrivileges(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  Principal principal=deserializeNext(arguments);
  LOG.trace("String_Node_Str",principal);
  Set<Privilege> privileges=privilegesManager.listPrivileges(principal);
  LOG.debug("String_Node_Str",principal,privileges);
  responder.sendJson(HttpResponseStatus.OK,privileges);
}
Program: 5033
Project: 5033
Buggy source:
@POST @Path("String_Node_Str") public void revokeAll(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  EntityId entityId=deserializeNext(arguments);
  LOG.trace("String_Node_Str",entityId);
  authorizer.revoke(entityId);
  LOG.debug("String_Node_Str",entityId);
  responder.sendStatus(HttpResponseStatus.OK);
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void revokeAll(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  EntityId entityId=deserializeNext(arguments);
  LOG.trace("String_Node_Str",entityId);
  privilegesManager.revoke(entityId);
  LOG.info("String_Node_Str",entityId);
  responder.sendStatus(HttpResponseStatus.OK);
}
Program: 5034
Project: 5034
Buggy source:
@POST @Path("String_Node_Str") public void enforce(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  EntityId entityId=deserializeNext(arguments);
  Principal principal=deserializeNext(arguments);
  Action action=deserializeNext(arguments);
  LOG.trace("String_Node_Str",action,entityId,principal);
  authorizer.enforce(entityId,principal,action);
  responder.sendStatus(HttpResponseStatus.OK);
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void enforce(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  EntityId entityId=deserializeNext(arguments);
  Principal principal=deserializeNext(arguments);
  Action action=deserializeNext(arguments);
  LOG.debug("String_Node_Str",action,entityId,principal);
  authorizationEnforcer.enforce(entityId,principal,action);
  responder.sendStatus(HttpResponseStatus.OK);
}
Program: 5035
Project: 5035
Buggy source:
@POST @Path("String_Node_Str") public void revoke(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  EntityId entityId=deserializeNext(arguments);
  Principal principal=deserializeNext(arguments);
  Set<Action> actions=deserializeNext(arguments,SET_OF_ACTIONS);
  LOG.trace("String_Node_Str",actions,entityId,principal);
  authorizer.revoke(entityId,principal,actions);
  LOG.debug("String_Node_Str",actions,entityId,principal);
  responder.sendStatus(HttpResponseStatus.OK);
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void revoke(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  EntityId entityId=deserializeNext(arguments);
  Principal principal=deserializeNext(arguments);
  Set<Action> actions=deserializeNext(arguments,SET_OF_ACTIONS);
  LOG.trace("String_Node_Str",actions,entityId,principal);
  privilegesManager.revoke(entityId,principal,actions);
  LOG.info("String_Node_Str",actions,entityId,principal);
  responder.sendStatus(HttpResponseStatus.OK);
}
Program: 5036
Project: 5036
Buggy source:
@Inject RemotePrivilegesHandler(AuthorizerInstantiator authorizerInstantiator){
  this.authorizer=authorizerInstantiator.get();
}

Fixed version (ground truth):
@Inject RemotePrivilegesHandler(PrivilegesManager privilegesManager,AuthorizationEnforcer authorizationEnforcer){
  this.privilegesManager=privilegesManager;
  this.authorizationEnforcer=authorizationEnforcer;
}
Program: 5037
Project: 5037
Buggy source:
@POST @Path("String_Node_Str") public void grant(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  EntityId entityId=deserializeNext(arguments);
  Principal principal=deserializeNext(arguments);
  Set<Action> actions=deserializeNext(arguments,SET_OF_ACTIONS);
  LOG.trace("String_Node_Str",actions,entityId,principal);
  authorizer.grant(entityId,principal,actions);
  LOG.debug("String_Node_Str",actions,entityId,principal);
  responder.sendStatus(HttpResponseStatus.OK);
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void grant(HttpRequest request,HttpResponder responder) throws Exception {
  Iterator<MethodArgument> arguments=parseArguments(request);
  EntityId entityId=deserializeNext(arguments);
  Principal principal=deserializeNext(arguments);
  Set<Action> actions=deserializeNext(arguments,SET_OF_ACTIONS);
  LOG.debug("String_Node_Str",actions,entityId,principal);
  privilegesManager.grant(entityId,principal,actions);
  LOG.info("String_Node_Str",actions,entityId,principal);
  responder.sendStatus(HttpResponseStatus.OK);
}
Program: 5038
Project: 5038
Buggy source:
@Test public void testPrivilegesManager() throws Exception {
  privilegesManager.grant(NS,ALICE,EnumSet.allOf(Action.class));
  privilegesManager.grant(APP,ALICE,Collections.singleton(Action.ADMIN));
  privilegesManager.grant(PROGRAM,ALICE,Collections.singleton(Action.EXECUTE));
  authorizationEnforcer.enforce(NS,ALICE,EnumSet.allOf(Action.class));
  authorizationEnforcer.enforce(APP,ALICE,Action.ADMIN);
  authorizationEnforcer.enforce(PROGRAM,ALICE,Action.EXECUTE);
  try {
    authorizer.enforce(APP,ALICE,EnumSet.allOf(Action.class));
    Assert.fail("String_Node_Str");
  }
 catch (  UnauthorizedException e) {
  }
  privilegesManager.revoke(PROGRAM);
  privilegesManager.revoke(APP,ALICE,EnumSet.allOf(Action.class));
  privilegesManager.revoke(NS,ALICE,EnumSet.allOf(Action.class));
  Set<Privilege> privileges=authorizer.listPrivileges(ALICE);
  Assert.assertTrue(String.format("String_Node_Str",privileges),privileges.isEmpty());
}

Fixed version (ground truth):
@Test public void testPrivilegesManager() throws Exception {
  privilegesManager.grant(NS,ALICE,EnumSet.allOf(Action.class));
  privilegesManager.grant(APP,ALICE,Collections.singleton(Action.ADMIN));
  privilegesManager.grant(PROGRAM,ALICE,Collections.singleton(Action.EXECUTE));
  authorizationEnforcer.enforce(NS,ALICE,EnumSet.allOf(Action.class));
  authorizationEnforcer.enforce(APP,ALICE,Action.ADMIN);
  authorizationEnforcer.enforce(PROGRAM,ALICE,Action.EXECUTE);
  try {
    authorizationEnforcer.enforce(APP,ALICE,EnumSet.allOf(Action.class));
    Assert.fail("String_Node_Str");
  }
 catch (  UnauthorizedException e) {
  }
  privilegesManager.revoke(PROGRAM);
  privilegesManager.revoke(APP,ALICE,EnumSet.allOf(Action.class));
  privilegesManager.revoke(NS,ALICE,EnumSet.allOf(Action.class));
  Set<Privilege> privileges=privilegesManager.listPrivileges(ALICE);
  Assert.assertTrue(String.format("String_Node_Str",privileges),privileges.isEmpty());
}
Program: 5039
Project: 5039
Buggy source:
@BeforeClass public static void setup() throws IOException, InterruptedException {
  CConfiguration cConf=CConfiguration.create();
  cConf.set(Constants.CFG_LOCAL_DATA_DIR,TEMPORARY_FOLDER.newFolder().getAbsolutePath());
  cConf.setBoolean(Constants.Security.ENABLED,true);
  cConf.setBoolean(Constants.Security.KERBEROS_ENABLED,false);
  cConf.setBoolean(Constants.Security.Authorization.ENABLED,true);
  cConf.setBoolean(Constants.Security.Authorization.CACHE_ENABLED,true);
  cConf.setInt(Constants.Security.Authorization.CACHE_TTL_SECS,CACHE_TIMEOUT);
  Manifest manifest=new Manifest();
  manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS,InMemoryAuthorizer.class.getName());
  LocationFactory locationFactory=new LocalLocationFactory(TEMPORARY_FOLDER.newFolder());
  Location externalAuthJar=AppJarHelper.createDeploymentJar(locationFactory,InMemoryAuthorizer.class,manifest);
  cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH,externalAuthJar.toString());
  Injector injector=AppFabricTestHelper.getInjector(cConf);
  discoveryService=injector.getInstance(DiscoveryServiceClient.class);
  appFabricServer=injector.getInstance(AppFabricServer.class);
  appFabricServer.startAndWait();
  waitForService(Constants.Service.APP_FABRIC_HTTP);
  authorizationEnforcer=injector.getInstance(RemoteAuthorizationEnforcer.class);
  authorizer=injector.getInstance(AuthorizerInstantiator.class).get();
  privilegesManager=injector.getInstance(PrivilegesManager.class);
}

Fixed version (ground truth):
@BeforeClass public static void setup() throws IOException, InterruptedException {
  CConfiguration cConf=CConfiguration.create();
  cConf.set(Constants.CFG_LOCAL_DATA_DIR,TEMPORARY_FOLDER.newFolder().getAbsolutePath());
  cConf.setBoolean(Constants.Security.ENABLED,true);
  cConf.setBoolean(Constants.Security.KERBEROS_ENABLED,false);
  cConf.setBoolean(Constants.Security.Authorization.ENABLED,true);
  cConf.setBoolean(Constants.Security.Authorization.CACHE_ENABLED,true);
  cConf.setInt(Constants.Security.Authorization.CACHE_TTL_SECS,CACHE_TIMEOUT);
  Manifest manifest=new Manifest();
  manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS,InMemoryAuthorizer.class.getName());
  LocationFactory locationFactory=new LocalLocationFactory(TEMPORARY_FOLDER.newFolder());
  Location externalAuthJar=AppJarHelper.createDeploymentJar(locationFactory,InMemoryAuthorizer.class,manifest);
  cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH,externalAuthJar.toString());
  Injector injector=AppFabricTestHelper.getInjector(cConf);
  discoveryService=injector.getInstance(DiscoveryServiceClient.class);
  appFabricServer=injector.getInstance(AppFabricServer.class);
  appFabricServer.startAndWait();
  waitForService(Constants.Service.APP_FABRIC_HTTP);
  authorizationEnforcer=injector.getInstance(RemoteAuthorizationEnforcer.class);
  privilegesManager=injector.getInstance(PrivilegesManager.class);
}
Program: 5041
Project: 5041
Buggy source:
private void addPluginsInRangeToMap(final NamespaceId namespace,List<Id.Artifact> parentArtifacts,Map<byte[],byte[]> columns,SortedMap<ArtifactDescriptor,PluginClass> plugins,@Nullable Predicate<co.cask.cdap.proto.id.ArtifactId> range,int limit){
  range=range != null ? range : new Predicate<co.cask.cdap.proto.id.ArtifactId>(){
    @Override public boolean apply(    co.cask.cdap.proto.id.ArtifactId input){
      return NamespaceId.SYSTEM.equals(input.getParent()) || input.getParent().equals(namespace);
    }
  }
;
  for (  Map.Entry<byte[],byte[]> column : columns.entrySet()) {
    if (limit != Integer.MAX_VALUE && limit == plugins.size()) {
      break;
    }
    ArtifactColumn artifactColumn=ArtifactColumn.parse(column.getKey());
    if (!range.apply(artifactColumn.artifactId.toEntityId())) {
      continue;
    }
    PluginData pluginData=GSON.fromJson(Bytes.toString(column.getValue()),PluginData.class);
    for (    Id.Artifact parentArtifactId : parentArtifacts) {
      if (pluginData.usableBy.versionIsInRange(parentArtifactId.getVersion())) {
        plugins.put(new ArtifactDescriptor(artifactColumn.artifactId.toArtifactId(),Locations.getLocationFromAbsolutePath(locationFactory,pluginData.getArtifactLocationPath())),pluginData.pluginClass);
        break;
      }
    }
  }
}

Fixed version (ground truth):
private void addPluginsInRangeToMap(final NamespaceId namespace,List<Id.Artifact> parentArtifacts,Map<byte[],byte[]> columns,SortedMap<ArtifactDescriptor,PluginClass> plugins,@Nullable Predicate<co.cask.cdap.proto.id.ArtifactId> range,int limit){
  range=range != null ? range : new Predicate<co.cask.cdap.proto.id.ArtifactId>(){
    @Override public boolean apply(    co.cask.cdap.proto.id.ArtifactId input){
      return NamespaceId.SYSTEM.equals(input.getParent()) || input.getParent().equals(namespace);
    }
  }
;
  for (  Map.Entry<byte[],byte[]> column : columns.entrySet()) {
    ArtifactColumn artifactColumn=ArtifactColumn.parse(column.getKey());
    if (!range.apply(artifactColumn.artifactId.toEntityId())) {
      continue;
    }
    PluginData pluginData=GSON.fromJson(Bytes.toString(column.getValue()),PluginData.class);
    for (    Id.Artifact parentArtifactId : parentArtifacts) {
      if (pluginData.usableBy.versionIsInRange(parentArtifactId.getVersion())) {
        plugins.put(new ArtifactDescriptor(artifactColumn.artifactId.toArtifactId(),Locations.getLocationFromAbsolutePath(locationFactory,pluginData.getArtifactLocationPath())),pluginData.pluginClass);
        break;
      }
    }
    if (limit < plugins.size()) {
      plugins.remove(plugins.lastKey());
    }
  }
}
Program: 5045
Project: 5045
Buggy source:
@Override public void failed(Service.State from,Throwable failure){
  LOG.error("String_Node_Str",failure);
  serviceStoppedLatch.countDown();
  error(failure);
}

Fixed version (ground truth):
@Override public void failed(Service.State from,Throwable failure){
  LOG.error("String_Node_Str",getProgramRunId().getType(),getProgramRunId().getProgram(),failure);
  serviceStoppedLatch.countDown();
  error(failure);
}
Program: 5046
Project: 5046
Buggy source:
private void listenToRuntimeState(Service service){
  service.addListener(new ServiceListenerAdapter(){
    @Override public void running(){
      started();
    }
    @Override public void failed(    Service.State from,    Throwable failure){
      LOG.error("String_Node_Str",failure);
      serviceStoppedLatch.countDown();
      error(failure);
    }
    @Override public void terminated(    Service.State from){
      serviceStoppedLatch.countDown();
      if (from != Service.State.STOPPING) {
        complete();
      }
 else {
        stop();
      }
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
}

Fixed version (ground truth):
private void listenToRuntimeState(Service service){
  service.addListener(new ServiceListenerAdapter(){
    @Override public void running(){
      started();
    }
    @Override public void failed(    Service.State from,    Throwable failure){
      LOG.error("String_Node_Str",getProgramRunId().getType(),getProgramRunId().getProgram(),failure);
      serviceStoppedLatch.countDown();
      error(failure);
    }
    @Override public void terminated(    Service.State from){
      serviceStoppedLatch.countDown();
      if (from != Service.State.STOPPING) {
        complete();
      }
 else {
        stop();
      }
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
}
Program: 5047
Project: 5047
Buggy source:
@Override public void run(){
  try {
    String programName=getContext().getSpecification().getProperties().get(PROGRAM_NAME);
    if (programWorkflowRunner == null) {
      throw new UnsupportedOperationException("String_Node_Str");
    }
    Runnable programRunner=programWorkflowRunner.create(programName);
    LOG.info("String_Node_Str",programName);
    programRunner.run();
    LOG.info("String_Node_Str",programType != null ? programType.name() : null,programName);
  }
 catch (  Exception e) {
    LOG.info("String_Node_Str",programType,programName,e);
    throw e;
  }
}

Fixed version (ground truth):
@Override public void run(){
  String prettyProgramType=ProgramType.valueOf(programType.name()).getPrettyName();
  String programName=getContext().getSpecification().getProperties().get(PROGRAM_NAME);
  if (programWorkflowRunner == null) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  Runnable programRunner=programWorkflowRunner.create(programName);
  LOG.info("String_Node_Str",prettyProgramType,programName);
  programRunner.run();
  LOG.info("String_Node_Str",prettyProgramType,programName);
}
Program: 5048
Project: 5048
Buggy source:
@Override protected void startUp() throws Exception {
  LoggingContextAccessor.setLoggingContext(loggingContext);
  httpService=NettyHttpService.builder().setWorkerThreadPoolSize(2).setExecThreadPoolSize(4).setHost(hostname.getHostName()).addHttpHandlers(ImmutableList.of(new WorkflowServiceHandler(createStatusSupplier()))).build();
  httpService.startAndWait();
  runningThread=Thread.currentThread();
  createLocalDatasets();
  workflow=initializeWorkflow();
}

Fixed version (ground truth):
@Override protected void startUp() throws Exception {
  LoggingContextAccessor.setLoggingContext(loggingContext);
  httpService=NettyHttpService.builder(workflowRunId.getProgram() + "String_Node_Str").setWorkerThreadPoolSize(2).setExecThreadPoolSize(4).setHost(hostname.getHostName()).addHttpHandlers(ImmutableList.of(new WorkflowServiceHandler(createStatusSupplier()))).build();
  httpService.startAndWait();
  runningThread=Thread.currentThread();
  createLocalDatasets();
  workflow=initializeWorkflow();
}
Program: 5049
Project: 5049
Buggy source:
@Override public void running(){
  InetSocketAddress endpoint=driver.getServiceEndpoint();
  cancelAnnounce=serviceAnnouncer.announce(serviceName,endpoint.getPort());
  LOG.info("String_Node_Str",serviceName,endpoint);
  started();
}

Fixed version (ground truth):
@Override public void running(){
  InetSocketAddress endpoint=driver.getServiceEndpoint();
  cancelAnnounce=serviceAnnouncer.announce(serviceName,endpoint.getPort());
  LOG.debug("String_Node_Str",serviceName,endpoint);
  started();
}
Program: 5050
Project: 5050
Buggy source:
private void startListen(Service service){
  service.addListener(new ServiceListenerAdapter(){
    @Override public void running(){
      InetSocketAddress endpoint=driver.getServiceEndpoint();
      cancelAnnounce=serviceAnnouncer.announce(serviceName,endpoint.getPort());
      LOG.info("String_Node_Str",serviceName,endpoint);
      started();
    }
    @Override public void terminated(    Service.State from){
      LOG.info("String_Node_Str",from,serviceName);
      cancelAnnounce.cancel();
      LOG.info("String_Node_Str",serviceName);
      if (getState() != State.STOPPING) {
        complete();
      }
 else {
        stop();
      }
    }
    @Override public void failed(    Service.State from,    Throwable failure){
      LOG.info("String_Node_Str",from,serviceName,failure);
      if (cancelAnnounce != null) {
        cancelAnnounce.cancel();
      }
      LOG.info("String_Node_Str",serviceName);
      error(failure);
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
}

Fixed version (ground truth):
private void startListen(Service service){
  service.addListener(new ServiceListenerAdapter(){
    @Override public void running(){
      InetSocketAddress endpoint=driver.getServiceEndpoint();
      cancelAnnounce=serviceAnnouncer.announce(serviceName,endpoint.getPort());
      LOG.debug("String_Node_Str",serviceName,endpoint);
      started();
    }
    @Override public void terminated(    Service.State from){
      LOG.debug("String_Node_Str",from,serviceName);
      cancelAnnounce.cancel();
      LOG.debug("String_Node_Str",serviceName);
      if (getState() != State.STOPPING) {
        complete();
      }
 else {
        stop();
      }
    }
    @Override public void failed(    Service.State from,    Throwable failure){
      LOG.info("String_Node_Str",from,serviceName,failure);
      if (cancelAnnounce != null) {
        cancelAnnounce.cancel();
      }
      LOG.info("String_Node_Str",serviceName);
      error(failure);
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
}
Program: 5051
Project: 5051
Buggy source:
@Override public void terminated(Service.State from){
  LOG.info("String_Node_Str",from,serviceName);
  cancelAnnounce.cancel();
  LOG.info("String_Node_Str",serviceName);
  if (getState() != State.STOPPING) {
    complete();
  }
 else {
    stop();
  }
}

Fixed version (ground truth):
@Override public void terminated(Service.State from){
  LOG.debug("String_Node_Str",from,serviceName);
  cancelAnnounce.cancel();
  LOG.debug("String_Node_Str",serviceName);
  if (getState() != State.STOPPING) {
    complete();
  }
 else {
    stop();
  }
}
Program: 5053
Project: 5053
Buggy source:
private void initFlowlet() throws InterruptedException {
  LOG.info("String_Node_Str" + flowletContext);
  try {
    try {
      flowletContext.initializeProgram(flowlet,flowletContext,Transactions.getTransactionControl(TransactionControl.IMPLICIT,Flowlet.class,flowlet,"String_Node_Str",FlowletContext.class),false);
      LOG.info("String_Node_Str" + flowletContext);
    }
 catch (    TransactionFailureException e) {
      throw e.getCause() == null ? e : e.getCause();
    }
  }
 catch (  Throwable cause) {
    LOG.error("String_Node_Str" + flowletContext,cause);
    throw Throwables.propagate(cause);
  }
}

Fixed version (ground truth):
private void initFlowlet() throws InterruptedException {
  LOG.debug("String_Node_Str",flowletContext);
  try {
    try {
      flowletContext.initializeProgram(flowlet,flowletContext,Transactions.getTransactionControl(TransactionControl.IMPLICIT,Flowlet.class,flowlet,"String_Node_Str",FlowletContext.class),false);
      LOG.debug("String_Node_Str",flowletContext);
    }
 catch (    TransactionFailureException e) {
      throw e.getCause() == null ? e : e.getCause();
    }
  }
 catch (  Throwable cause) {
    LOG.error("String_Node_Str",flowletContext,cause);
    throw Throwables.propagate(cause);
  }
}
Program: 5054
Project: 5054
Buggy source:
@Override protected void startUp() throws Exception {
  LoggingContextAccessor.setLoggingContext(flowletContext.getLoggingContext());
  flowletContext.getProgramMetrics().increment("String_Node_Str",1);
  flowletProcessDriver=new FlowletProcessDriver(flowletContext,dataFabricFacade,txCallback,processSpecs);
  serviceHook.startAndWait();
  initFlowlet();
  flowletProcessDriver.startAndWait();
}

Fixed version (ground truth):
@Override protected void startUp() throws Exception {
  LoggingContextAccessor.setLoggingContext(flowletContext.getLoggingContext());
  flowletContext.getProgramMetrics().increment("String_Node_Str",1);
  flowletProcessDriver=new FlowletProcessDriver(flowletContext,dataFabricFacade,txCallback,processSpecs);
  serviceHook.startAndWait();
  initFlowlet();
  flowletProcessDriver.startAndWait();
  LOG.info("String_Node_Str",flowletContext.getFlowletId(),flowletContext.getFlowId(),flowletContext);
}
Program: 5055
Project: 5055
Buggy source:
private void destroyFlowlet(){
  LOG.info("String_Node_Str" + flowletContext);
  try {
    try {
      flowletContext.destroyProgram(flowlet,flowletContext,Transactions.getTransactionControl(TransactionControl.IMPLICIT,Flowlet.class,flowlet,"String_Node_Str"),false);
      LOG.info("String_Node_Str" + flowletContext);
    }
 catch (    TransactionFailureException e) {
      throw e.getCause() == null ? e : e.getCause();
    }
  }
 catch (  Throwable cause) {
    LOG.error("String_Node_Str" + flowletContext,cause);
    throw Throwables.propagate(cause);
  }
}

Fixed version (ground truth):
private void destroyFlowlet(){
  LOG.debug("String_Node_Str",flowletContext);
  try {
    try {
      flowletContext.destroyProgram(flowlet,flowletContext,Transactions.getTransactionControl(TransactionControl.IMPLICIT,Flowlet.class,flowlet,"String_Node_Str"),false);
      LOG.debug("String_Node_Str",flowletContext);
    }
 catch (    TransactionFailureException e) {
      throw e.getCause() == null ? e : e.getCause();
    }
  }
 catch (  Throwable cause) {
    LOG.error("String_Node_Str",flowletContext,cause);
    throw Throwables.propagate(cause);
  }
}
Program: 5056
Project: 5056
Buggy source:
@Override protected void shutDown() throws Exception {
  LoggingContextAccessor.setLoggingContext(flowletContext.getLoggingContext());
  if (flowletProcessDriver != null) {
    stopService(flowletProcessDriver);
  }
  destroyFlowlet();
  stopService(serviceHook);
}

Fixed version (ground truth):
@Override protected void shutDown() throws Exception {
  LoggingContextAccessor.setLoggingContext(flowletContext.getLoggingContext());
  if (flowletProcessDriver != null) {
    stopService(flowletProcessDriver);
  }
  destroyFlowlet();
  LOG.info("String_Node_Str",flowletContext.getFlowletId(),flowletContext.getInstanceId(),flowletContext.getFlowId());
  stopService(serviceHook);
}
Program: 5057
Project: 5057
Buggy source:
@Override public void cancel(){
  if (Thread.currentThread() == saveCurrentThread && !cancelled) {
    MDC.setContextMap(saveContextMap);
    loggingContext.set(saveLoggingContext);
    cancelled=true;
  }
}

Fixed version (ground truth):
@Override public void cancel(){
  if (Thread.currentThread() == saveCurrentThread && !cancelled) {
    MDC.setContextMap(saveContextMap == null ? Collections.emptyMap() : saveContextMap);
    loggingContext.set(saveLoggingContext);
    cancelled=true;
  }
}
Program: 5058
Project: 5058
Buggy source:
/** 
 * Sets the logging context. <p> NOTE: in work execution frameworks where threads are shared between workers (like Akka) we would have to init context very frequently (before every chunk of work is started). In that case we really want to re-use logging context object instance. </p>
 * @param context context to set
 * @return Cancellable that can be used to revert the logging context and MDC Map to its original value
 */
public static Cancellable setLoggingContext(LoggingContext context){
  final LoggingContext saveLoggingContext=loggingContext.get();
  final Map saveContextMap=MDC.getCopyOfContextMap();
  final Thread saveCurrentThread=Thread.currentThread();
  loggingContext.set(context);
  try {
    MDC.setContextMap(context.getSystemTagsAsString());
  }
 catch (  IllegalStateException e) {
  }
  return new Cancellable(){
    private boolean cancelled;
    @Override public void cancel(){
      if (Thread.currentThread() == saveCurrentThread && !cancelled) {
        MDC.setContextMap(saveContextMap);
        loggingContext.set(saveLoggingContext);
        cancelled=true;
      }
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Sets the logging context. <p> NOTE: in work execution frameworks where threads are shared between workers (like Akka) we would have to init context very frequently (before every chunk of work is started). In that case we really want to re-use logging context object instance. </p>
 * @param context context to set
 * @return Cancellable that can be used to revert the logging context and MDC Map to its original value
 */
public static Cancellable setLoggingContext(LoggingContext context){
  final LoggingContext saveLoggingContext=loggingContext.get();
  final Map saveContextMap=MDC.getCopyOfContextMap();
  final Thread saveCurrentThread=Thread.currentThread();
  loggingContext.set(context);
  try {
    MDC.setContextMap(context.getSystemTagsAsString());
  }
 catch (  IllegalStateException e) {
  }
  return new Cancellable(){
    private boolean cancelled;
    @Override public void cancel(){
      if (Thread.currentThread() == saveCurrentThread && !cancelled) {
        MDC.setContextMap(saveContextMap == null ? Collections.emptyMap() : saveContextMap);
        loggingContext.set(saveLoggingContext);
        cancelled=true;
      }
    }
  }
;
}