nus-yam/ex-repair huggingface dataset:
Program: 89967
Project: 89967
Buggy source:
private void unbindService(Context context){
  if (isServiceBound) {
    try {
      context.unbindService(serviceConnection);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
    }
  }
}

Fixed version (ground truth):
private void unbindService(Context context){
  if (isServiceBound) {
    try {
      context.unbindService(serviceConnection);
      isServiceBound=false;
    }
 catch (    Exception ex) {
      ex.printStackTrace();
    }
  }
}
Program: 89968
Project: 89968
Buggy source:
/** 
 * Initializes the smart location with custom options
 * @param context
 */
public void start(Context context,SmartLocationOptions options){
  setOptions(options);
  bindService(context);
}

Fixed version (ground truth):
/** 
 * Initializes the smart location with custom options
 * @param context
 */
public void start(Context context,SmartLocationOptions options){
  setOptions(options);
  if (isServiceBound) {
    boundService.startLocation(smartLocationOptions);
  }
 else {
    bindService(context);
  }
}
Program: 89969
Project: 89969
Buggy source:
private void createServiceConnection(IBinder iBinder){
  boundService=((SmartLocationService.LocalBinder)iBinder).getService();
  isServiceConnected=(boundService != null);
  String packageName=null;
  if (smartLocationOptions != null) {
    packageName=smartLocationOptions.getPackageName();
  }
  if (boundService != null) {
    boundService.startLocation(smartLocationOptions);
  }
}

Fixed version (ground truth):
private void createServiceConnection(IBinder iBinder){
  boundService=((SmartLocationService.LocalBinder)iBinder).getService();
  isServiceConnected=(boundService != null);
  if (boundService != null) {
    boundService.startLocation(smartLocationOptions);
  }
}
Program: 89970
Project: 89970
Buggy source:
/** 
 * Convert a V4 Job Request DTO into a gRPC resolve job specification request to be sent to the server.
 * @param jobRequest The job request to convert
 * @return The request that should be sent to the server for a new Job Specification given the parameters
 * @throws JsonProcessingException if any serialization errors occur
 */
public static ResolveJobSpecificationRequest toProtoResolveJobSpecificationRequest(final AgentJobRequest jobRequest){
  final ResolveJobSpecificationRequest.Builder builder=ResolveJobSpecificationRequest.newBuilder().setIsInteractive(jobRequest.isInteractive()).setCriteria(toProtoExecutionResourceCriteria(jobRequest.getCriteria()));
  jobRequest.getRequestedId().ifPresent(builder::setId);
  jobRequest.getRequestedJobDirectoryLocation().ifPresent(location -> builder.setJobDirectoryLocation(location.getAbsolutePath()));
  return builder.build();
}

Fixed version (ground truth):
/** 
 * Convert a V4 Job Request DTO into a gRPC resolve job specification request to be sent to the server.
 * @param jobRequest The job request to convert
 * @return The request that should be sent to the server for a new Job Specification given the parameters
 */
public static ResolveJobSpecificationRequest toProtoResolveJobSpecificationRequest(final AgentJobRequest jobRequest){
  final ResolveJobSpecificationRequest.Builder builder=ResolveJobSpecificationRequest.newBuilder().setIsInteractive(jobRequest.isInteractive()).setCriteria(toProtoExecutionResourceCriteria(jobRequest.getCriteria()));
  jobRequest.getRequestedId().ifPresent(builder::setId);
  jobRequest.getRequestedJobDirectoryLocation().ifPresent(location -> builder.setJobDirectoryLocation(location.getAbsolutePath()));
  return builder.build();
}
Program: 89971
Project: 89971
Buggy source:
/** 
 * Set the ordered list of command line arguments to append to the command executable at runtime.
 * @param commandArgs The arguments in the order they should be placed on the command line. Maximum of 10,000characters per argument
 * @return The builder
 */
public Builder withCommandArgs(@Nullable final List<String> commandArgs){
  this.bCommandArgs=commandArgs == null ? ImmutableList.of() : ImmutableList.copyOf(commandArgs);
  return this;
}

Fixed version (ground truth):
/** 
 * Set the ordered list of command line arguments to append to the command executable at runtime.
 * @param commandArgs The arguments in the order they should be placed on the command line. Maximum of 10,000characters per argument. Blank strings are removed
 * @return The builder
 */
public Builder withCommandArgs(@Nullable final List<String> commandArgs){
  this.bCommandArgs=commandArgs == null ? ImmutableList.of() : ImmutableList.copyOf(commandArgs.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList()));
  return this;
}
Program: 89972
Project: 89972
Buggy source:
/** 
 * Set the ordered list of command line arguments to append to the command executable at runtime.
 * @param commandArgs The arguments in the order they should be placed on the command line. Maximum of 10,000characters per argument
 * @return The builder
 */
public Builder withCommandArgs(@Nullable final List<String> commandArgs){
  this.bCommandArgs=commandArgs == null ? ImmutableList.of() : ImmutableList.copyOf(commandArgs);
  return this;
}

Fixed version (ground truth):
/** 
 * Set the ordered list of command line arguments to append to the command executable at runtime.
 * @param commandArgs The arguments in the order they should be placed on the command line. Maximum of 10,000characters per argument. Any blanks will be removed
 * @return The builder
 */
public Builder withCommandArgs(@Nullable final List<String> commandArgs){
  this.bCommandArgs=commandArgs == null ? ImmutableList.of() : ImmutableList.copyOf(commandArgs.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList()));
  return this;
}
Program: 89973
Project: 89973
Buggy source:
/** 
 * Set the type of this application resource.
 * @param type The type (e.g. Hadoop, Spark, etc) for grouping applications
 * @return The builder
 */
public Builder withType(@Nullable final String type){
  this.bType=type;
  return this;
}

Fixed version (ground truth):
/** 
 * Set the type of this application resource.
 * @param type The type (e.g. Hadoop, Spark, etc) for grouping applications
 * @return The builder
 */
public Builder withType(@Nullable final String type){
  this.bType=StringUtils.isBlank(type) ? null : type;
  return this;
}
Program: 89975
Project: 89975
Buggy source:
/** 
 * Constructor which has required fields.
 * @param metadata   The user supplied metadata about a command resource
 * @param executable The executable arguments to use on job process launch. Typically the binary path followedby optional default parameters for that given binary. Must have at least one
 */
@JsonCreator public Builder(@JsonProperty(value="String_Node_Str",required=true) final CommandMetadata metadata,@JsonProperty(value="String_Node_Str",required=true) final List<String> executable){
  super();
  this.bMetadata=metadata;
  this.bExecutable=ImmutableList.copyOf(executable);
}

Fixed version (ground truth):
/** 
 * Constructor which has required fields.
 * @param metadata   The user supplied metadata about a command resource
 * @param executable The executable arguments to use on job process launch. Typically the binary path followedby optional default parameters for that given binary. Must have at least one. Blanks will be removed
 */
@JsonCreator public Builder(@JsonProperty(value="String_Node_Str",required=true) final CommandMetadata metadata,@JsonProperty(value="String_Node_Str",required=true) final List<String> executable){
  super();
  this.bMetadata=metadata;
  this.bExecutable=ImmutableList.copyOf(executable.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList()));
}
Program: 89976
Project: 89976
Buggy source:
/** 
 * Set the tags to use for the resource.
 * @param tags The tags to use
 * @return The builder
 */
public T withTags(@Nullable final Set<String> tags){
  this.bTags=tags == null ? ImmutableSet.of() : ImmutableSet.copyOf(tags);
  return (T)this;
}

Fixed version (ground truth):
/** 
 * Set the tags to use for the resource.
 * @param tags The tags to use. Blanks will be removed
 * @return The builder
 */
public T withTags(@Nullable final Set<String> tags){
  this.bTags=tags == null ? ImmutableSet.of() : ImmutableSet.copyOf(tags.stream().filter(StringUtils::isNotBlank).collect(Collectors.toSet()));
  return (T)this;
}
Program: 89977
Project: 89977
Buggy source:
/** 
 * Set the description for the resource.
 * @param description The description to use
 * @return The builder
 */
public T withDescription(@Nullable final String description){
  this.bDescription=description;
  return (T)this;
}

Fixed version (ground truth):
/** 
 * Set the description for the resource.
 * @param description The description to use
 * @return The builder
 */
public T withDescription(@Nullable final String description){
  this.bDescription=StringUtils.isBlank(description) ? null : description;
  return (T)this;
}
Program: 89978
Project: 89978
Buggy source:
/** 
 * Set the version of the resource.
 * @param version The version to set
 * @return The builder
 */
public T withVersion(@Nullable final String version){
  this.bVersion=version;
  return (T)this;
}

Fixed version (ground truth):
/** 
 * Set the version of the resource.
 * @param version The version to set
 * @return The builder
 */
public T withVersion(@Nullable final String version){
  this.bVersion=StringUtils.isBlank(version) ? null : version;
  return (T)this;
}
Program: 89979
Project: 89979
Buggy source:
/** 
 * Set the id being requested for the resource. Will be rejected if the ID is already used by another resource of the same type. If not included a GUID will be supplied.
 * @param requestedId The requested id. Max of 255 characters.
 * @return The builder
 */
public T withRequestedId(@Nullable final String requestedId){
  this.bRequestedId=requestedId;
  return (T)this;
}

Fixed version (ground truth):
/** 
 * Set the id being requested for the resource. Will be rejected if the ID is already used by another resource of the same type. If not included a GUID will be supplied.
 * @param requestedId The requested id. Max of 255 characters.
 * @return The builder
 */
public T withRequestedId(@Nullable final String requestedId){
  this.bRequestedId=StringUtils.isBlank(requestedId) ? null : requestedId;
  return (T)this;
}
Program: 89980
Project: 89980
Buggy source:
/** 
 * Set the status to search for. Overrides default status of resource in search algorithm.
 * @param status The status to override the default with
 * @return The builder
 */
public Builder withStatus(@Nullable final String status){
  this.bStatus=status;
  return this;
}

Fixed version (ground truth):
/** 
 * Set the status to search for. Overrides default status of resource in search algorithm.
 * @param status The status to override the default with
 * @return The builder
 */
public Builder withStatus(@Nullable final String status){
  this.bStatus=StringUtils.isBlank(status) ? null : status;
  return this;
}
Program: 89981
Project: 89981
Buggy source:
/** 
 * Set the tags to use in the search.
 * @param tags The tags
 * @return The builder
 */
public Builder withTags(@Nullable final Set<String> tags){
  this.bTags=tags == null ? ImmutableSet.of() : ImmutableSet.copyOf(tags);
  return this;
}

Fixed version (ground truth):
/** 
 * Set the tags to use in the search.
 * @param tags The tags. Any blanks will be removed
 * @return The builder
 */
public Builder withTags(@Nullable final Set<String> tags){
  this.bTags=tags == null ? ImmutableSet.of() : ImmutableSet.copyOf(tags.stream().filter(StringUtils::isNotBlank).collect(Collectors.toSet()));
  return this;
}
Program: 89982
Project: 89982
Buggy source:
Criterion(final Builder builder) throws GeniePreconditionException {
  this.id=builder.bId;
  this.name=builder.bName;
  this.status=builder.bStatus;
  this.tags=builder.bTags == null ? ImmutableSet.of() : ImmutableSet.copyOf(builder.bTags);
  if (StringUtils.isEmpty(this.id) && StringUtils.isEmpty(this.name) && StringUtils.isEmpty(this.status)&& this.tags.isEmpty()) {
    throw new GeniePreconditionException("String_Node_Str");
  }
}

Fixed version (ground truth):
private Criterion(final Builder builder) throws GeniePreconditionException {
  this.id=builder.bId;
  this.name=builder.bName;
  this.status=builder.bStatus;
  this.tags=builder.bTags == null ? ImmutableSet.of() : ImmutableSet.copyOf(builder.bTags);
  if (StringUtils.isEmpty(this.id) && StringUtils.isEmpty(this.name) && StringUtils.isEmpty(this.status)&& this.tags.isEmpty()) {
    throw new GeniePreconditionException("String_Node_Str");
  }
}
Program: 89983
Project: 89983
Buggy source:
/** 
 * Set the name of the resource (cluster, command, etc) to search for.
 * @param name The name of the resource
 * @return The builder
 */
public Builder withName(@Nullable final String name){
  this.bName=name;
  return this;
}

Fixed version (ground truth):
/** 
 * Set the name of the resource (cluster, command, etc) to search for.
 * @param name The name of the resource
 * @return The builder
 */
public Builder withName(@Nullable final String name){
  this.bName=StringUtils.isBlank(name) ? null : name;
  return this;
}
Program: 89984
Project: 89984
Buggy source:
/** 
 * Set the id of the resource (cluster, command, etc) to use.
 * @param id The id
 * @return The builder
 */
public Builder withId(@Nullable final String id){
  this.bId=id;
  return this;
}

Fixed version (ground truth):
/** 
 * Set the id of the resource (cluster, command, etc) to use.
 * @param id The id
 * @return The builder
 */
public Builder withId(@Nullable final String id){
  this.bId=StringUtils.isBlank(id) ? null : id;
  return this;
}
Program: 89985
Project: 89985
Buggy source:
/** 
 * Get the name of the resource desired if it exists.
 * @return {@link Optional<String>} wrapping the name
 */
public Optional<String> getName(){
  return Optional.ofNullable(this.name);
}

Fixed version (ground truth):
/** 
 * Get the name of the resource desired if it exists.
 * @return {@link Optional} wrapping the name
 */
public Optional<String> getName(){
  return Optional.ofNullable(this.name);
}
Program: 89986
Project: 89986
Buggy source:
/** 
 * Get the id of the resource desired if it exists.
 * @return {@link Optional<String>} wrapping the id
 */
public Optional<String> getId(){
  return Optional.ofNullable(this.id);
}

Fixed version (ground truth):
/** 
 * Get the id of the resource desired if it exists.
 * @return {@link Optional} wrapping the id
 */
public Optional<String> getId(){
  return Optional.ofNullable(this.id);
}
Program: 89987
Project: 89987
Buggy source:
/** 
 * Get the desired status of the resource if it has been set by the creator.
 * @return {@link Optional<String>} wrapping the status
 */
public Optional<String> getStatus(){
  return Optional.ofNullable(this.status);
}

Fixed version (ground truth):
/** 
 * Get the desired status of the resource if it has been set by the creator.
 * @return {@link Optional} wrapping the status
 */
public Optional<String> getStatus(){
  return Optional.ofNullable(this.status);
}
Program: 89988
Project: 89988
Buggy source:
/** 
 * Set the timeout (in seconds) that the job should be killed after by the service after it has started.
 * @param timeout The timeout. Must be greater >= 1 but preferably much higher
 * @return The builder
 */
public Builder withTimeout(@Nullable final Integer timeout){
  this.bTimeout=timeout;
  return this;
}

Fixed version (ground truth):
/** 
 * Set the timeout (in seconds) that the job should be killed after by the service after it has started.
 * @param timeout The timeout. Must be greater greater than or equal to 1 but preferably much higher
 * @return The builder
 */
public Builder withTimeout(@Nullable final Integer timeout){
  this.bTimeout=timeout;
  return this;
}
Program: 89989
Project: 89989
Buggy source:
/** 
 * Submit the job for appropriate execution based on environment.
 * @param jobRequest   of job to run
 * @param cluster      The cluster this job should run on
 * @param command      the command to run this job with
 * @param applications Any applications that are needed to run the command
 * @param memory       The amount of memory (in MB) to use to run the job
 * @throws GenieException if there is an error
 */
void submitJob(@Valid @NotNull(message="String_Node_Str") final JobRequest jobRequest,@Valid @NotNull(message="String_Node_Str") final Cluster cluster,@Valid @NotNull(message="String_Node_Str") final Command command,@NotNull(message="String_Node_Str") final List<Application> applications,@Min(value=1,message="String_Node_Str") final int memory) throws GenieException ;

Fixed version (ground truth):
/** 
 * Submit the job for appropriate execution based on environment.
 * @param jobRequest   of job to run
 * @param cluster      The cluster this job should run on
 * @param command      the command to run this job with
 * @param applications Any applications that are needed to run the command
 * @param memory       The amount of memory (in MB) to use to run the job
 * @throws GenieException if there is an error
 */
void submitJob(@NotNull(message="String_Node_Str") @Valid final JobRequest jobRequest,@NotNull(message="String_Node_Str") @Valid final Cluster cluster,@NotNull(message="String_Node_Str") @Valid final Command command,@NotNull(message="String_Node_Str") final List<Application> applications,@Min(value=1,message="String_Node_Str") final int memory) throws GenieException ;
Program: 89993
Project: 89993
Buggy source:
/** 
 * Setup the tests.
 * @throws GenieException If there is a problem.
 */
@Before public void setup() throws GenieException {
  this.registry=Mockito.mock(Registry.class);
  this.downloadTimer=Mockito.mock(Timer.class);
  this.downloadTimerId=Mockito.mock(Id.class);
  this.uploadTimer=Mockito.mock(Timer.class);
  this.uploadTimerId=Mockito.mock(Id.class);
  this.urlFailingStrictValidationCounter=Mockito.mock(Counter.class);
  Mockito.when(registry.createId("String_Node_Str")).thenReturn(this.downloadTimerId);
  Mockito.when(downloadTimerId.withTags(Mockito.anyMap())).thenReturn(downloadTimerId);
  Mockito.when(registry.timer(Mockito.eq(downloadTimerId))).thenReturn(downloadTimer);
  Mockito.when(registry.createId("String_Node_Str")).thenReturn(this.uploadTimerId);
  Mockito.when(uploadTimerId.withTags(Mockito.anyMap())).thenReturn(uploadTimerId);
  Mockito.when(registry.timer(Mockito.eq(uploadTimerId))).thenReturn(uploadTimer);
  Mockito.when(registry.counter("String_Node_Str")).thenReturn(urlFailingStrictValidationCounter);
  this.s3Client=Mockito.mock(AmazonS3Client.class);
  this.s3FileTransferProperties=Mockito.mock(S3FileTransferProperties.class);
  this.s3FileTransfer=new S3FileTransferImpl(this.s3Client,registry,s3FileTransferProperties);
  this.tagsCaptor=ArgumentCaptor.forClass(Map.class);
}

Fixed version (ground truth):
/** 
 * Setup the tests.
 * @throws GenieException If there is a problem.
 */
@Before public void setup() throws GenieException {
  MockitoAnnotations.initMocks(this);
  final Registry registry=Mockito.mock(Registry.class);
  this.downloadTimer=Mockito.mock(Timer.class);
  this.downloadTimerId=Mockito.mock(Id.class);
  this.uploadTimer=Mockito.mock(Timer.class);
  this.uploadTimerId=Mockito.mock(Id.class);
  this.urlFailingStrictValidationCounter=Mockito.mock(Counter.class);
  Mockito.when(registry.createId("String_Node_Str")).thenReturn(this.downloadTimerId);
  Mockito.when(this.downloadTimerId.withTags(Mockito.anyMapOf(String.class,String.class))).thenReturn(this.downloadTimerId);
  Mockito.when(registry.timer(Mockito.eq(this.downloadTimerId))).thenReturn(this.downloadTimer);
  Mockito.when(registry.createId("String_Node_Str")).thenReturn(this.uploadTimerId);
  Mockito.when(this.uploadTimerId.withTags(Mockito.anyMapOf(String.class,String.class))).thenReturn(this.uploadTimerId);
  Mockito.when(registry.timer(Mockito.eq(this.uploadTimerId))).thenReturn(this.uploadTimer);
  Mockito.when(registry.counter("String_Node_Str")).thenReturn(this.urlFailingStrictValidationCounter);
  this.s3Client=Mockito.mock(AmazonS3Client.class);
  this.s3FileTransferProperties=Mockito.mock(S3FileTransferProperties.class);
  this.s3FileTransfer=new S3FileTransferImpl(this.s3Client,registry,this.s3FileTransferProperties);
}
Program: 89994
Project: 89994
Buggy source:
private Void updateJob(final Job job,final JobFinishedEvent event,Map<String,String> tags) throws GenieException {
  try {
    final String jobId=event.getId();
    final JobStatus status=job.getStatus();
    JobStatus eventStatus=null;
    if (status == JobStatus.INIT) {
switch (event.getReason()) {
case KILLED:
        eventStatus=JobStatus.KILLED;
      break;
case INVALID:
    eventStatus=JobStatus.INVALID;
  break;
case FAILED_TO_INIT:
eventStatus=JobStatus.FAILED;
break;
case PROCESS_COMPLETED:
eventStatus=JobStatus.SUCCEEDED;
break;
case SYSTEM_CRASH:
eventStatus=JobStatus.FAILED;
break;
default :
eventStatus=JobStatus.INVALID;
log.warn("String_Node_Str",jobId);
}
}
 else {
if (event.getReason() != JobFinishedReason.SYSTEM_CRASH) {
try {
final String finalStatus=this.retryTemplate.execute(context -> updateFinalStatusForJob(jobId).toString());
tags.put(JOB_FINAL_STATE,finalStatus);
cleanupProcesses(jobId);
}
 catch (Exception e) {
log.error("String_Node_Str",jobId,e);
}
}
 else {
tags.put(JOB_FINAL_STATE,JobStatus.FAILED.toString());
eventStatus=JobStatus.FAILED;
}
}
if (eventStatus != null) {
tags.put(JOB_FINAL_STATE,status.toString());
this.jobPersistenceService.updateJobStatus(jobId,eventStatus,event.getMessage());
}
}
 catch (Throwable t) {
incrementErrorCounter("String_Node_Str",t);
throw t;
}
return null;
}

Fixed version (ground truth):
private Void updateJob(final Job job,final JobFinishedEvent event,final Map<String,String> tags) throws GenieException {
  try {
    final String jobId=event.getId();
    final JobStatus status=job.getStatus();
    JobStatus eventStatus=null;
    if (status == JobStatus.INIT) {
switch (event.getReason()) {
case KILLED:
        eventStatus=JobStatus.KILLED;
      break;
case INVALID:
    eventStatus=JobStatus.INVALID;
  break;
case FAILED_TO_INIT:
eventStatus=JobStatus.FAILED;
break;
case PROCESS_COMPLETED:
eventStatus=JobStatus.SUCCEEDED;
break;
case SYSTEM_CRASH:
eventStatus=JobStatus.FAILED;
break;
default :
eventStatus=JobStatus.INVALID;
log.warn("String_Node_Str",jobId);
}
}
 else {
if (event.getReason() != JobFinishedReason.SYSTEM_CRASH) {
try {
final String finalStatus=this.retryTemplate.execute(context -> updateFinalStatusForJob(jobId).toString());
tags.put(JOB_FINAL_STATE,finalStatus);
cleanupProcesses(jobId);
}
 catch (Exception e) {
log.error("String_Node_Str",jobId,e);
}
}
 else {
tags.put(JOB_FINAL_STATE,JobStatus.FAILED.toString());
eventStatus=JobStatus.FAILED;
}
}
if (eventStatus != null) {
tags.put(JOB_FINAL_STATE,status.toString());
this.jobPersistenceService.updateJobStatus(jobId,eventStatus,event.getMessage());
}
}
 catch (Throwable t) {
incrementErrorCounter("String_Node_Str",t);
throw t;
}
return null;
}
Program: 89996
Project: 89996
Buggy source:
/** 
 * Constructor.
 * @param fileTransferFactory file transfer implementation factory
 * @param baseCacheLocation file cache location
 * @param localFileTransfer Local file transfer service
 * @param registry spectator registry
 * @throws GenieException If there is any problem
 */
public CacheGenieFileTransferService(@NotNull final FileTransferFactory fileTransferFactory,@NotNull final String baseCacheLocation,@NotNull final FileTransfer localFileTransfer,@NotNull final Registry registry) throws GenieException {
  super(fileTransferFactory);
  this.baseCacheLocation=createDirectories(baseCacheLocation).toString();
  this.localFileTransfer=localFileTransfer;
  registry.gauge("String_Node_Str",fileCache,(ToDoubleFunction<LoadingCache<String,File>>)value -> value.stats().hitRate());
  registry.gauge("String_Node_Str",fileCache,(ToDoubleFunction<LoadingCache<String,File>>)value -> value.stats().missRate());
  registry.gauge("String_Node_Str",fileCache,(ToDoubleFunction<LoadingCache<String,File>>)value -> value.stats().loadExceptionRate());
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param fileTransferFactory file transfer implementation factory
 * @param baseCacheLocation   file cache location
 * @param localFileTransfer   Local file transfer service
 * @param registry            spectator registry
 * @throws GenieException If there is any problem
 */
public CacheGenieFileTransferService(@NotNull final FileTransferFactory fileTransferFactory,@NotNull final String baseCacheLocation,@NotNull final FileTransfer localFileTransfer,@NotNull final Registry registry) throws GenieException {
  super(fileTransferFactory);
  this.baseCacheLocation=this.createDirectories(baseCacheLocation).toString();
  this.localFileTransfer=localFileTransfer;
  registry.gauge("String_Node_Str",fileCache,(ToDoubleFunction<LoadingCache<String,File>>)value -> value.stats().hitRate());
  registry.gauge("String_Node_Str",fileCache,(ToDoubleFunction<LoadingCache<String,File>>)value -> value.stats().missRate());
  registry.gauge("String_Node_Str",fileCache,(ToDoubleFunction<LoadingCache<String,File>>)value -> value.stats().loadExceptionRate());
}
Program: 89997
Project: 89997
Buggy source:
/** 
 * Get the file needed by Genie for job execution.
 * @param srcRemotePath Path of the file in the remote location to be fetched
 * @param dstLocalPath  Local path where the file needs to be placed
 * @throws GenieException If there is any problem
 */
public void getFile(@NotBlank(message="String_Node_Str") final String srcRemotePath,@NotBlank(message="String_Node_Str") final String dstLocalPath) throws GenieException {
  log.debug("String_Node_Str",srcRemotePath,dstLocalPath);
  File cachedFile=null;
  try {
    cachedFile=fileCache.get(srcRemotePath);
    final long lastModifiedTime=getFileTransfer(srcRemotePath).getLastModifiedTime(srcRemotePath);
    if (lastModifiedTime > cachedFile.lastModified()) {
synchronized (this) {
        if (lastModifiedTime > cachedFile.lastModified()) {
          fileCache.invalidate(srcRemotePath);
          deleteFile(cachedFile);
          cachedFile=fileCache.get(srcRemotePath);
        }
      }
    }
  }
 catch (  Exception e) {
    final String message=String.format("String_Node_Str",srcRemotePath);
    log.error(message);
    throw new GenieServerException(message,e);
  }
  localFileTransfer.getFile(cachedFile.getPath(),dstLocalPath);
}

Fixed version (ground truth):
/** 
 * Get the file needed by Genie for job execution.
 * @param srcRemotePath Path of the file in the remote location to be fetched
 * @param dstLocalPath  Local path where the file needs to be placed
 * @throws GenieException If there is any problem
 */
public void getFile(@NotBlank(message="String_Node_Str") final String srcRemotePath,@NotBlank(message="String_Node_Str") final String dstLocalPath) throws GenieException {
  log.debug("String_Node_Str",srcRemotePath,dstLocalPath);
  File cachedFile;
  try {
    cachedFile=fileCache.get(srcRemotePath);
    final long lastModifiedTime=getFileTransfer(srcRemotePath).getLastModifiedTime(srcRemotePath);
    if (lastModifiedTime > cachedFile.lastModified()) {
synchronized (this) {
        if (lastModifiedTime > cachedFile.lastModified()) {
          fileCache.invalidate(srcRemotePath);
          deleteFile(cachedFile);
          cachedFile=fileCache.get(srcRemotePath);
        }
      }
    }
  }
 catch (  Exception e) {
    final String message=String.format("String_Node_Str",srcRemotePath);
    log.error(message);
    throw new GenieServerException(message,e);
  }
  localFileTransfer.getFile(cachedFile.getPath(),dstLocalPath);
}
Program: 89998
Project: 89998
Buggy source:
protected Path createDirectories(final String path) throws GenieException {
  Path result=null;
  try {
    final File pathFile=new File(new URI(path).getPath());
    result=pathFile.toPath();
    if (!Files.exists(result)) {
      Files.createDirectories(result);
    }
  }
 catch (  Exception e) {
    throw new GenieServerException("String_Node_Str" + path,e);
  }
  return result;
}

Fixed version (ground truth):
protected Path createDirectories(final String path) throws GenieException {
  try {
    final File pathFile=new File(new URI(path).getPath());
    final Path result=pathFile.toPath();
    if (!Files.exists(result)) {
      Files.createDirectories(result);
    }
    return result;
  }
 catch (  Exception e) {
    throw new GenieServerException("String_Node_Str" + path,e);
  }
}
Program: 89999
Project: 89999
Buggy source:
/** 
 * Get the file needed by Genie for job execution.
 * @param srcRemotePath Path of the file in the remote location to be fetched
 * @param dstLocalPath  Local path where the file needs to be placed
 * @throws GenieException If there is any problem
 */
public void getFile(@NotBlank(message="String_Node_Str") final String srcRemotePath,@NotBlank(message="String_Node_Str") final String dstLocalPath) throws GenieException {
  log.debug("String_Node_Str",srcRemotePath,dstLocalPath);
  getFileTransfer(srcRemotePath).getFile(srcRemotePath,dstLocalPath);
}

Fixed version (ground truth):
/** 
 * Get the file needed by Genie for job execution.
 * @param srcRemotePath Path of the file in the remote location to be fetched
 * @param dstLocalPath  Local path where the file needs to be placed
 * @throws GenieException If there is any problem
 */
public void getFile(@NotBlank(message="String_Node_Str") final String srcRemotePath,@NotBlank(message="String_Node_Str") final String dstLocalPath) throws GenieException {
  log.debug("String_Node_Str",srcRemotePath,dstLocalPath);
  this.getFileTransfer(srcRemotePath).getFile(srcRemotePath,dstLocalPath);
}
Program: 90000
Project: 90000
Buggy source:
/** 
 * Put the file provided by Genie.
 * @param srcLocalPath  The local path of the file which has to be transfered to remote location
 * @param dstRemotePath The remote destination path where the file has to be put
 * @throws GenieException If there is any problem
 */
public void putFile(@NotBlank(message="String_Node_Str") final String srcLocalPath,@NotBlank(message="String_Node_Str") final String dstRemotePath) throws GenieException {
  log.debug("String_Node_Str",srcLocalPath,dstRemotePath);
  getFileTransfer(dstRemotePath).putFile(srcLocalPath,dstRemotePath);
}

Fixed version (ground truth):
/** 
 * Put the file provided by Genie.
 * @param srcLocalPath  The local path of the file which has to be transfered to remote location
 * @param dstRemotePath The remote destination path where the file has to be put
 * @throws GenieException If there is any problem
 */
public void putFile(@NotBlank(message="String_Node_Str") final String srcLocalPath,@NotBlank(message="String_Node_Str") final String dstRemotePath) throws GenieException {
  log.debug("String_Node_Str",srcLocalPath,dstRemotePath);
  this.getFileTransfer(dstRemotePath).putFile(srcLocalPath,dstRemotePath);
}
Program: 90001
Project: 90001
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public long getLastModifiedTime(final String path) throws GenieException {
  try {
    return new File(path).lastModified();
  }
 catch (  Exception e) {
    final String message=String.format("String_Node_Str",path);
    log.error(message);
    throw new GenieServerException(message,e);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public long getLastModifiedTime(final String path) throws GenieException {
  try {
    return new File(path).lastModified();
  }
 catch (  Exception e) {
    final String message=String.format("String_Node_Str",path);
    log.error(message,e);
    throw new GenieServerException(message,e);
  }
}
Program: 90002
Project: 90002
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void getFile(@NotBlank(message="String_Node_Str") final String srcRemotePath,@NotBlank(message="String_Node_Str") final String dstLocalPath) throws GenieException {
  log.debug("String_Node_Str",srcRemotePath,dstLocalPath);
  try {
    final File src=new File(srcRemotePath);
    final File dest=new File(dstLocalPath);
    Files.copy(src.toPath(),dest.toPath(),StandardCopyOption.REPLACE_EXISTING);
  }
 catch (  IOException ioe) {
    log.error("String_Node_Str",srcRemotePath,dstLocalPath);
    throw new GenieServerException("String_Node_Str" + srcRemotePath + "String_Node_Str"+ dstLocalPath,ioe);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void getFile(@NotBlank(message="String_Node_Str") final String srcRemotePath,@NotBlank(message="String_Node_Str") final String dstLocalPath) throws GenieException {
  log.debug("String_Node_Str",srcRemotePath,dstLocalPath);
  this.copy(srcRemotePath,dstLocalPath);
}
Program: 90003
Project: 90003
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void putFile(@NotBlank(message="String_Node_Str") final String srcLocalPath,@NotBlank(message="String_Node_Str") final String dstRemotePath) throws GenieException {
  log.debug("String_Node_Str",srcLocalPath,dstRemotePath);
  try {
    final File src=new File(srcLocalPath);
    final File dest=new File(dstRemotePath);
    Files.copy(src.toPath(),dest.toPath(),StandardCopyOption.REPLACE_EXISTING);
  }
 catch (  IOException ioe) {
    log.error("String_Node_Str",srcLocalPath,dstRemotePath);
    throw new GenieServerException("String_Node_Str" + srcLocalPath + "String_Node_Str"+ dstRemotePath,ioe);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void putFile(@NotBlank(message="String_Node_Str") final String srcLocalPath,@NotBlank(message="String_Node_Str") final String dstRemotePath) throws GenieException {
  log.debug("String_Node_Str",srcLocalPath,dstRemotePath);
  this.copy(srcLocalPath,dstRemotePath);
}
Program: 90006
Project: 90006
Buggy source:
/** 
 * Constructor.
 * @param runAsUserEnabled    Flag that tells if job should be run as user specified in the request
 * @param userCreationEnabled Flag that tells if the user specified should be created
 * @param executor            An executor object used to run jobs
 * @param hostname            Hostname for the node the job is running on
 * @param registry            The metrics registry to use
 */
public JobKickoffTask(final boolean runAsUserEnabled,final boolean userCreationEnabled,@NotNull final Executor executor,@NotNull final String hostname,@NotNull final Registry registry){
  this.isRunAsUserEnabled=runAsUserEnabled;
  this.isUserCreationEnabled=userCreationEnabled;
  this.executor=executor;
  this.hostname=hostname;
  this.timer=registry.timer("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param runAsUserEnabled    Flag that tells if job should be run as user specified in the request
 * @param userCreationEnabled Flag that tells if the user specified should be created
 * @param executor            An executor object used to run jobs
 * @param hostname            Hostname for the node the job is running on
 * @param registry            The metrics registry to use
 */
public JobKickoffTask(final boolean runAsUserEnabled,final boolean userCreationEnabled,@NotNull final Executor executor,@NotNull final String hostname,@NotNull final Registry registry){
  this.isRunAsUserEnabled=runAsUserEnabled;
  this.isUserCreationEnabled=userCreationEnabled;
  this.executor=executor;
  this.hostname=hostname;
  this.registry=registry;
  this.timer=registry.timer("String_Node_Str");
  retryTemplate=new RetryTemplate();
  retryTemplate.setBackOffPolicy(new ExponentialBackOffPolicy());
}
Program: 90007
Project: 90007
Buggy source:
/** 
 * Method to change the ownership of a directory.
 * @param dir  The directory to change the ownership of.
 * @param user Userid of the user.
 * @throws GenieException If there is a problem.
 */
protected void changeOwnershipOfDirectory(final String dir,final String user) throws GenieException {
  final CommandLine commandLine=new CommandLine("String_Node_Str");
  commandLine.addArgument("String_Node_Str");
  commandLine.addArgument("String_Node_Str");
  commandLine.addArgument(user);
  commandLine.addArgument(dir);
  try {
    this.executor.execute(commandLine);
  }
 catch (  IOException ioexception) {
    throw new GenieServerException("String_Node_Str" + ioexception);
  }
}

Fixed version (ground truth):
/** 
 * Method to change the ownership of a directory.
 * @param dir  The directory to change the ownership of.
 * @param user Userid of the user.
 * @throws GenieException If there is a problem.
 */
protected void changeOwnershipOfDirectory(final String dir,final String user) throws GenieException {
  final CommandLine commandLine=new CommandLine("String_Node_Str").addArgument("String_Node_Str").addArgument("String_Node_Str").addArgument(user).addArgument(dir);
  try {
    this.executor.execute(commandLine);
  }
 catch (  IOException ioexception) {
    throw new GenieServerException("String_Node_Str" + ioexception);
  }
}
Program: 90009
Project: 90009
Buggy source:
private void makeDirGroupWritable(final String dir) throws GenieServerException {
  log.debug("String_Node_Str" + dir + "String_Node_Str");
  final CommandLine commandLIne=new CommandLine("String_Node_Str");
  commandLIne.addArgument("String_Node_Str");
  commandLIne.addArgument("String_Node_Str");
  commandLIne.addArgument(dir);
  try {
    this.executor.execute(commandLIne);
  }
 catch (  IOException ioe) {
    throw new GenieServerException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void makeDirGroupWritable(final String dir) throws GenieServerException {
  log.debug("String_Node_Str" + dir + "String_Node_Str");
  final CommandLine commandLIne=new CommandLine("String_Node_Str").addArgument("String_Node_Str").addArgument("String_Node_Str").addArgument(dir);
  try {
    this.executor.execute(commandLIne);
  }
 catch (  IOException ioe) {
    throw new GenieServerException("String_Node_Str");
  }
}
Program: 90011
Project: 90011
Buggy source:
/** 
 * Constructor.
 * @param jobRepository          The repository to use for job entities
 * @param jobRequestRepository   The repository to use for job request entities
 * @param jobExecutionRepository The repository to use for job execution entities
 */
public JpaJobSearchServiceImpl(final JpaJobRepository jobRepository,final JpaJobRequestRepository jobRequestRepository,final JpaJobExecutionRepository jobExecutionRepository){
  this.jobRepository=jobRepository;
  this.jobRequestRepository=jobRequestRepository;
  this.jobExecutionRepository=jobExecutionRepository;
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param jobRepository          The repository to use for job entities
 * @param jobRequestRepository   The repository to use for job request entities
 * @param jobExecutionRepository The repository to use for job execution entities
 * @param clusterRepository      The repository to use for cluster entities
 * @param commandRepository      The repository to use for command entities
 */
public JpaJobSearchServiceImpl(final JpaJobRepository jobRepository,final JpaJobRequestRepository jobRequestRepository,final JpaJobExecutionRepository jobExecutionRepository,final JpaClusterRepository clusterRepository,final JpaCommandRepository commandRepository){
  this.jobRepository=jobRepository;
  this.jobRequestRepository=jobRequestRepository;
  this.jobExecutionRepository=jobExecutionRepository;
  this.clusterRepository=clusterRepository;
  this.commandRepository=commandRepository;
}
Program: 90013
Project: 90013
Buggy source:
/** 
 * Get JPA based implementation of the JobSearchService.
 * @param jobRepository          The repository to use for job entities
 * @param jobRequestRepository   The repository to use for job request entities
 * @param jobExecutionRepository The repository to use for job execution entities
 * @return A job search service instance.
 */
@Bean public JobSearchService jobSearchService(final JpaJobRepository jobRepository,final JpaJobRequestRepository jobRequestRepository,final JpaJobExecutionRepository jobExecutionRepository){
  return new JpaJobSearchServiceImpl(jobRepository,jobRequestRepository,jobExecutionRepository);
}

Fixed version (ground truth):
/** 
 * Get JPA based implementation of the JobSearchService.
 * @param jobRepository          The repository to use for job entities
 * @param jobRequestRepository   The repository to use for job request entities
 * @param jobExecutionRepository The repository to use for job execution entities
 * @param clusterRepository      The repository to use for cluster entities
 * @param commandRepository      The repository to use for command entities
 * @return A job search service instance.
 */
@Bean public JobSearchService jobSearchService(final JpaJobRepository jobRepository,final JpaJobRequestRepository jobRequestRepository,final JpaJobExecutionRepository jobExecutionRepository,final JpaClusterRepository clusterRepository,final JpaCommandRepository commandRepository){
  return new JpaJobSearchServiceImpl(jobRepository,jobRequestRepository,jobExecutionRepository,clusterRepository,commandRepository);
}
Program: 90014
Project: 90014
Buggy source:
/** 
 * Setup for the tests.
 */
@Before public void setup(){
  this.jobRepository=Mockito.mock(JpaJobRepository.class);
  this.jobRequestRepository=Mockito.mock(JpaJobRequestRepository.class);
  this.jobExecutionRepository=Mockito.mock(JpaJobExecutionRepository.class);
  this.service=new JpaJobSearchServiceImpl(this.jobRepository,this.jobRequestRepository,this.jobExecutionRepository);
}

Fixed version (ground truth):
/** 
 * Setup for the tests.
 */
@Before public void setup(){
  this.jobRepository=Mockito.mock(JpaJobRepository.class);
  this.jobRequestRepository=Mockito.mock(JpaJobRequestRepository.class);
  this.jobExecutionRepository=Mockito.mock(JpaJobExecutionRepository.class);
  this.service=new JpaJobSearchServiceImpl(this.jobRepository,this.jobRequestRepository,this.jobExecutionRepository,Mockito.mock(JpaClusterRepository.class),Mockito.mock(JpaCommandRepository.class));
}
Program: 90015
Project: 90015
Buggy source:
/** 
 * Get the file needed by Genie for job execution.
 * @param srcRemotePath Path of the file in the remote location to be fetched
 * @param dstLocalPath  Local path where the file needs to be placed
 * @throws GenieException If there is any problem
 */
public void getFile(@NotBlank(message="String_Node_Str") final String srcRemotePath,@NotBlank(message="String_Node_Str") final String dstLocalPath) throws GenieException {
  log.debug("String_Node_Str",srcRemotePath,dstLocalPath);
  File cachedFile=fileCache.getIfPresent(srcRemotePath);
  try {
    if (cachedFile == null) {
      cachedFile=fileCache.get(srcRemotePath);
    }
 else {
      cachedFile=fileCache.get(srcRemotePath);
      final long lastModifiedTime=getFileTransfer(srcRemotePath).getLastModifiedTime(srcRemotePath);
      if (lastModifiedTime > cachedFile.lastModified()) {
synchronized (this) {
          if (lastModifiedTime > cachedFile.lastModified()) {
            fileCache.invalidate(srcRemotePath);
            deleteFile(cachedFile);
            cachedFile=fileCache.get(srcRemotePath);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    final String message=String.format("String_Node_Str",srcRemotePath);
    log.error(message);
    throw new GenieServerException(message,e);
  }
  localFileTransfer.getFile(cachedFile.getPath(),dstLocalPath);
}

Fixed version (ground truth):
/** 
 * Get the file needed by Genie for job execution.
 * @param srcRemotePath Path of the file in the remote location to be fetched
 * @param dstLocalPath  Local path where the file needs to be placed
 * @throws GenieException If there is any problem
 */
public void getFile(@NotBlank(message="String_Node_Str") final String srcRemotePath,@NotBlank(message="String_Node_Str") final String dstLocalPath) throws GenieException {
  log.debug("String_Node_Str",srcRemotePath,dstLocalPath);
  File cachedFile=null;
  try {
    cachedFile=fileCache.get(srcRemotePath);
    final long lastModifiedTime=getFileTransfer(srcRemotePath).getLastModifiedTime(srcRemotePath);
    if (lastModifiedTime > cachedFile.lastModified()) {
synchronized (this) {
        if (lastModifiedTime > cachedFile.lastModified()) {
          fileCache.invalidate(srcRemotePath);
          deleteFile(cachedFile);
          cachedFile=fileCache.get(srcRemotePath);
        }
      }
    }
  }
 catch (  Exception e) {
    final String message=String.format("String_Node_Str",srcRemotePath);
    log.error(message);
    throw new GenieServerException(message,e);
  }
  localFileTransfer.getFile(cachedFile.getPath(),dstLocalPath);
}
Program: 90016
Project: 90016
Buggy source:
/** 
 * Sends an email when the job is completed. Returns true if an email has been sent.
 * @param jobId The job id.
 * @throws GenieException If there is any problem.
 */
private boolean sendEmail(final String jobId) throws GenieException {
  log.debug("String_Node_Str");
  final JobRequest jobRequest=this.jobSearchService.getJobRequest(jobId);
  boolean result=false;
  final Optional<String> email=jobRequest.getEmail();
  if (email.isPresent() && Strings.isNullOrEmpty(email.get())) {
    final JobStatus status=this.jobSearchService.getJobStatus(jobId);
    this.mailServiceImpl.sendEmail(email.get(),"String_Node_Str" + jobId,"String_Node_Str" + jobId + "String_Node_Str"+ status);
    result=true;
    this.emailSuccessRate.increment();
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Sends an email when the job is completed. Returns true if an email has been sent.
 * @param jobId The job id.
 * @throws GenieException If there is any problem.
 */
private boolean sendEmail(final String jobId) throws GenieException {
  final JobRequest jobRequest=this.jobSearchService.getJobRequest(jobId);
  boolean result=false;
  final Optional<String> email=jobRequest.getEmail();
  if (email.isPresent() && !Strings.isNullOrEmpty(email.get())) {
    log.debug("String_Node_Str",email.get());
    final JobStatus status=this.jobSearchService.getJobStatus(jobId);
    this.mailServiceImpl.sendEmail(email.get(),"String_Node_Str" + jobId,"String_Node_Str" + jobId + "String_Node_Str"+ status);
    result=true;
    this.emailSuccessRate.increment();
  }
  return result;
}
Program: 90017
Project: 90017
Buggy source:
private void copyRequestHeaders(final HttpServletRequest request,final ClientHttpRequest forwardRequest){
  final HttpHeaders headers=forwardRequest.getHeaders();
  final Enumeration<String> headerNames=request.getHeaderNames();
  if (headerNames != null) {
    while (headerNames.hasMoreElements()) {
      final String headerName=headerNames.nextElement();
      final String headerValue=request.getHeader(headerName);
      log.debug("String_Node_Str",headerName,headerValue);
      headers.add(headerName,headerValue);
    }
  }
  headers.add(JobConstants.GENIE_FORWARDED_FROM_HEADER,request.getRequestURL().toString());
}

Fixed version (ground truth):
private void copyRequestHeaders(final HttpServletRequest request,final ClientHttpRequest forwardRequest){
  final HttpHeaders headers=forwardRequest.getHeaders();
  final Enumeration<String> headerNames=request.getHeaderNames();
  if (headerNames != null) {
    while (headerNames.hasMoreElements()) {
      final String headerName=headerNames.nextElement();
      if (!NAME_HEADER_COOKIE.equals(headerName)) {
        final String headerValue=request.getHeader(headerName);
        log.debug("String_Node_Str",headerName,headerValue);
        headers.add(headerName,headerValue);
      }
    }
  }
  final Cookie[] cookies=request.getCookies();
  if (cookies != null && cookies.length > 0) {
    StringBuilder builder=null;
    for (    final Cookie cookie : request.getCookies()) {
      if (builder == null) {
        builder=new StringBuilder();
      }
 else {
        builder.append("String_Node_Str");
      }
      builder.append(cookie.getName()).append("String_Node_Str").append(cookie.getValue());
    }
    if (builder != null) {
      final String cookieValue=builder.toString();
      headers.add(NAME_HEADER_COOKIE,cookieValue);
      log.debug("String_Node_Str",NAME_HEADER_COOKIE,cookieValue);
    }
  }
  headers.add(JobConstants.GENIE_FORWARDED_FROM_HEADER,request.getRequestURL().toString());
}