nus-yam/ex-repair huggingface dataset:
Program: 174130
Project: 174130
Buggy source:
/** 
 * creates a deploy shell script
 */
private void createDeployScript() throws IOException {
  BashScript deployScript=new BashScript(fileAccess,FILEPRAEFIX_DEPLOY + app.getName());
  deployScript.append(EnvironmentCheck.checkEnvironment("String_Node_Str"));
  if (app.getProvider() != null && !app.getServices().isEmpty()) {
    addProviderServiceOfferings(deployScript);
    for (    Map.Entry<String,CloudFoundryServiceType> service : app.getServices().entrySet()) {
      String description=service.getValue().getName();
      CloudFoundryProvider provider=app.getProvider();
      List<ServiceOffering> services=provider.getOfferedService();
      Boolean isSet=false;
      for (      ServiceOffering offeredService : services) {
        if (offeredService.getDescription().toLowerCase().indexOf(description.toLowerCase()) != -1) {
          for (          ServicePlan plan : offeredService.getServicePlans()) {
            if (plan.getFree()) {
              deployScript.append(String.format("String_Node_Str",CLI_CREATE_SERVICE,offeredService.getLabel(),plan.getName(),service.getKey()));
              isSet=true;
              break;
            }
          }
        }
      }
      if (!isSet) {
        deployScript.append(CLI_CREATE_SERVICE_DEFAULT + service);
      }
    }
  }
 else {
    for (    Map.Entry<String,CloudFoundryServiceType> service : app.getServices().entrySet()) {
      deployScript.append(CLI_CREATE_SERVICE_DEFAULT + service.getKey());
    }
  }
  deployScript.append(CLI_PUSH + app.getName());
}

Fixed version (ground truth):
/** 
 * creates a deploy shell script
 */
private void createDeployScript() throws IOException {
  BashScript deployScript=new BashScript(fileAccess,FILEPRAEFIX_DEPLOY + app.getName());
  deployScript.append(EnvironmentCheck.checkEnvironment("String_Node_Str"));
  if (app.getProvider() != null && !app.getServices().isEmpty()) {
    addProviderServiceOfferings(deployScript);
    for (    Map.Entry<String,CloudFoundryServiceType> service : app.getServices().entrySet()) {
      String description=service.getValue().getName();
      CloudFoundryProvider provider=app.getProvider();
      List<ServiceOffering> services=provider.getOfferedService();
      Boolean isSet=false;
      for (      ServiceOffering offeredService : services) {
        if (offeredService.getDescription().toLowerCase().indexOf(description.toLowerCase()) != -1) {
          for (          ServicePlan plan : offeredService.getServicePlans()) {
            if (plan.getFree()) {
              deployScript.append(String.format("String_Node_Str",CLI_CREATE_SERVICE,offeredService.getLabel(),plan.getName(),service.getKey()));
              isSet=true;
              break;
            }
          }
        }
      }
      if (!isSet) {
        deployScript.append(CLI_CREATE_SERVICE_DEFAULT + service);
      }
    }
  }
 else {
    for (    Map.Entry<String,CloudFoundryServiceType> service : app.getServices().entrySet()) {
      deployScript.append(CLI_CREATE_SERVICE_DEFAULT + service.getKey());
    }
  }
  deployScript.append(CLI_PUSH + app.getName() + CLI_PATH_TO_MANIFEST+ MANIFEST_NAME);
}
Program: 174131
Project: 174131
Buggy source:
private void createBuildpackAdditionsFile() throws IOException, JSONException {
  JSONObject buildPackAdditionsJson=new JSONObject();
  JSONArray buildPacks=new JSONArray();
  for (  String buildPack : app.getBuildpackAdditions()) {
    buildPacks.put(buildPack);
  }
  buildPackAdditionsJson.put(BUILDPACK_OBJECT_PHP,buildPacks);
  fileAccess.access(BUILDPACK_FILEPATH_PHP).append(buildPackAdditionsJson.toString(4)).close();
}

Fixed version (ground truth):
private void createBuildpackAdditionsFile() throws IOException, JSONException {
  JSONObject buildPackAdditionsJson=new JSONObject();
  JSONArray buildPacks=new JSONArray();
  for (  String buildPack : app.getBuildpackAdditions()) {
    buildPacks.put(buildPack);
  }
  buildPackAdditionsJson.put(BUILDPACK_OBJECT_PHP,buildPacks);
  String path;
  if (app.getPathToApplication() != null) {
    path=String.format("String_Node_Str",app.getPathToApplication(),BUILDPACK_FILEPATH_PHP);
  }
 else {
    path=BUILDPACK_FILEPATH_PHP;
  }
  fileAccess.access(path).append(buildPackAdditionsJson.toString(4)).close();
}
Program: 174132
Project: 174132
Buggy source:
private void createManifest() throws IOException {
  createManifestHead();
  createAttributes();
  createEnvironmentVariables();
  createService();
}

Fixed version (ground truth):
private void createManifest() throws IOException {
  createManifestHead();
  addPathToApplication();
  createAttributes();
  createEnvironmentVariables();
  createService();
}
Program: 174133
Project: 174133
Buggy source:
private void createManifestHead() throws IOException {
  String manifestHead=String.format("String_Node_Str",MANIFESTHEAD,NAMEBLOCK,app.getName());
  fileAccess.access(MANIFEST).appendln(manifestHead).close();
}

Fixed version (ground truth):
private void createManifestHead() throws IOException {
  String manifestHead=String.format("String_Node_Str",MANIFESTHEAD,NAMEBLOCK,app.getName());
  fileAccess.access(MANIFEST_PATH).appendln(manifestHead).close();
}
Program: 174134
Project: 174134
Buggy source:
private void createEnvironmentVariables() throws IOException {
  ArrayList<String> environmentVariables=new ArrayList<>();
  environmentVariables.add(String.format("String_Node_Str",ENVIRONMENT.getName()));
  for (  Map.Entry<String,String> entry : app.getEnvironmentVariables().entrySet()) {
    environmentVariables.add(String.format("String_Node_Str",entry.getKey(),entry.getValue()));
  }
  for (  String env : environmentVariables) {
    fileAccess.access(MANIFEST).appendln(env).close();
  }
}

Fixed version (ground truth):
private void createEnvironmentVariables() throws IOException {
  Map<String,String> envVariables=app.getEnvironmentVariables();
  if (!envVariables.isEmpty()) {
    ArrayList<String> environmentVariables=new ArrayList<>();
    environmentVariables.add(String.format("String_Node_Str",ENVIRONMENT.getName()));
    for (    Map.Entry<String,String> entry : envVariables.entrySet()) {
      environmentVariables.add(String.format("String_Node_Str",entry.getKey(),entry.getValue()));
    }
    for (    String env : environmentVariables) {
      fileAccess.access(MANIFEST_PATH).appendln(env).close();
    }
  }
}
Program: 174135
Project: 174135
Buggy source:
private void createAttributes() throws IOException {
  if (!app.getAttributes().isEmpty()) {
    ArrayList<String> attributes=new ArrayList<>();
    for (    Map.Entry<String,String> attribute : app.getAttributes().entrySet()) {
      attributes.add(String.format("String_Node_Str",attribute.getKey(),attribute.getValue()));
    }
    for (    String attribute : attributes) {
      fileAccess.access(MANIFEST).appendln(attribute).close();
    }
  }
}

Fixed version (ground truth):
private void createAttributes() throws IOException {
  if (!app.getAttributes().isEmpty()) {
    ArrayList<String> attributes=new ArrayList<>();
    for (    Map.Entry<String,String> attribute : app.getAttributes().entrySet()) {
      attributes.add(String.format("String_Node_Str",attribute.getKey(),attribute.getValue()));
    }
    for (    String attribute : attributes) {
      fileAccess.access(MANIFEST_PATH).appendln(attribute).close();
    }
  }
}
Program: 174136
Project: 174136
Buggy source:
private void handleStandardLifecycle(RootNode node){
  for (  OperationVariable lifecycleInput : node.getStandardLifecycle().getInputs()) {
    addEnvironmentVariable(lifecycleInput);
  }
  for (  Operation operation : node.getStandardLifecycle().getOperations()) {
    if (operation.getArtifact().isPresent()) {
      myApp.addFilePath(operation.getArtifact().get().getFilePath());
    }
    for (    String dependency : operation.getDependencies()) {
      myApp.addFilePath(dependency);
    }
    for (    OperationVariable input : operation.getInputs()) {
      addEnvironmentVariable(input);
    }
  }
}

Fixed version (ground truth):
private void handleStandardLifecycle(RootNode node,Boolean isTopNode){
  for (  OperationVariable lifecycleInput : node.getStandardLifecycle().getInputs()) {
    addEnvironmentVariable(lifecycleInput);
  }
  for (  Operation operation : node.getStandardLifecycle().getOperations()) {
    if (operation.getArtifact().isPresent()) {
      String path=operation.getArtifact().get().getFilePath();
      setPathToApplication(path,isTopNode);
    }
    for (    String dependency : operation.getDependencies()) {
      myApp.addFilePath(dependency);
    }
    for (    OperationVariable input : operation.getInputs()) {
      addEnvironmentVariable(input);
    }
  }
}
Program: 174137
Project: 174137
Buggy source:
@Override public void visit(WebApplication node){
  myApp.setName(node.getNodeName());
  handleStandardLifecycle(node);
}

Fixed version (ground truth):
@Override public void visit(WebApplication node){
  myApp.setName(node.getNodeName());
  handleStandardLifecycle(node,true);
}
Program: 174138
Project: 174138
Buggy source:
@Test public void buildpackAdditons() throws Exception {
  fileCreator.createFiles();
  File targetFile=new File(targetDir,BUILDPACK_FILEPATH_PHP);
  String buildpackContent=FileUtils.readFileToString(targetFile);
  assertEquals(expectedBuildpackcontent,buildpackContent);
}

Fixed version (ground truth):
@Test public void buildpackAdditons() throws Exception {
  String mainApplicationPath="String_Node_Str";
  String expectedPath="String_Node_Str" + "String_Node_Str" + BUILDPACK_FILEPATH_PHP;
  testApp.setPathToApplication(mainApplicationPath);
  testApp.addBuildpack(buildPack1);
  testApp.addBuildpack(buildPack2);
  String expectedBuildpackcontent="String_Node_Str" + "String_Node_Str" + BUILDPACK_OBJECT_PHP + "String_Node_Str"+ "String_Node_Str"+ buildPack1+ "String_Node_Str"+ "String_Node_Str"+ buildPack2+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  fileCreator.createFiles();
  File targetFile=new File(targetDir,expectedPath);
  String buildpackContent=FileUtils.readFileToString(targetFile);
  assertEquals(expectedBuildpackcontent,buildpackContent);
}
Program: 174139
Project: 174139
Buggy source:
@Test public void createFiles() throws Exception {
  fileCreator.createFiles();
  File targetFile=new File(targetDir,MANIFEST);
  File deployFile=new File(targetDir,outputPath + FILEPRAEFIX_DEPLOY + appName+ FILESUFFIX_DEPLOY);
  File buildPackAdditions=new File(targetDir,BUILDPACK_FILEPATH_PHP);
  assertTrue(targetFile.exists());
  assertTrue(deployFile.exists());
  assertTrue(buildPackAdditions.exists());
}

Fixed version (ground truth):
@Test public void createFiles() throws Exception {
  fileCreator.createFiles();
  File targetFile=new File(targetDir,MANIFEST_PATH);
  File deployFile=new File(targetDir,outputPath + FILEPRAEFIX_DEPLOY + appName+ FILESUFFIX_DEPLOY);
  File buildPackAdditions=new File(targetDir,BUILDPACK_FILEPATH_PHP);
  assertTrue(targetFile.exists());
  assertTrue(deployFile.exists());
  assertTrue(buildPackAdditions.exists());
}
Program: 174140
Project: 174140
Buggy source:
@Test public void contentManifest() throws Exception {
  fileCreator.createFiles();
  File targetFile=new File(targetDir,MANIFEST);
  String manifestContent=FileUtils.readFileToString(targetFile);
  String expectedManifestContent=String.format("String_Node_Str",APPLICATIONS_SECTION.getName(),NAMEBLOCK,appName,ENVIRONMENT.getName(),SERVICE.getName());
  assertEquals(expectedManifestContent,manifestContent);
}

Fixed version (ground truth):
@Test public void contentManifest() throws Exception {
  String mainApplicationPath="String_Node_Str";
  String expectedPath="String_Node_Str";
  testApp.setPathToApplication(mainApplicationPath);
  fileCreator.createFiles();
  File targetFile=new File(targetDir,MANIFEST_PATH);
  String manifestContent=FileUtils.readFileToString(targetFile);
  String expectedManifestContent=String.format("String_Node_Str",APPLICATIONS_SECTION.getName(),NAMEBLOCK,appName,PATH.getName(),expectedPath);
  assertEquals(expectedManifestContent,manifestContent);
}
Program: 174141
Project: 174141
Buggy source:
@Before public void setUp(){
  appName="String_Node_Str";
  testApp=new CloudFoundryApplication();
  testApp.setName(appName);
  testApp.addBuildpack("String_Node_Str");
  testApp.addBuildpack("String_Node_Str");
  File sourceDir=new File(tmpdir,"String_Node_Str");
  targetDir=new File(tmpdir,"String_Node_Str");
  sourceDir.mkdir();
  targetDir.mkdir();
  PluginFileAccess fileAccess=new PluginFileAccess(sourceDir,targetDir,log);
  fileCreator=new CloudFoundryFileCreator(fileAccess,testApp);
}

Fixed version (ground truth):
@Before public void setUp(){
  appName="String_Node_Str";
  testApp=new CloudFoundryApplication();
  testApp.setName(appName);
  File sourceDir=new File(tmpdir,"String_Node_Str");
  targetDir=new File(tmpdir,"String_Node_Str");
  sourceDir.mkdir();
  targetDir.mkdir();
  PluginFileAccess fileAccess=new PluginFileAccess(sourceDir,targetDir,log);
  fileCreator=new CloudFoundryFileCreator(fileAccess,testApp);
}
Program: 174142
Project: 174142
Buggy source:
@Test public void contentDeploy() throws Exception {
  fileCreator.createFiles();
  File targetFile=new File(targetDir,outputPath + FILEPRAEFIX_DEPLOY + appName+ FILESUFFIX_DEPLOY);
  String manifestContent=FileUtils.readFileToString(targetFile);
  String expectedDeployContent="String_Node_Str" + "String_Node_Str" + appName + "String_Node_Str";
  assertEquals(expectedDeployContent,manifestContent);
}

Fixed version (ground truth):
@Test public void contentDeploy() throws Exception {
  fileCreator.createFiles();
  File targetFile=new File(targetDir,outputPath + FILEPRAEFIX_DEPLOY + appName+ FILESUFFIX_DEPLOY);
  String manifestContent=FileUtils.readFileToString(targetFile);
  String expectedDeployContent="String_Node_Str" + "String_Node_Str" + appName + CLI_PATH_TO_MANIFEST+ MANIFEST_NAME+ "String_Node_Str";
  assertEquals(expectedDeployContent,manifestContent);
}
Program: 174143
Project: 174143
Buggy source:
@Builder protected Apache(String componentVersion,Credential adminCredential,ContainerCapability host,EndpointCapability databaseEndpoint,AdminEndpointCapability adminEndpoint,String NodeName,StandardLifecycle lifecycle,String description){
  super(componentVersion,adminCredential,host,databaseEndpoint,adminEndpoint,NodeName,lifecycle,description);
}

Fixed version (ground truth):
@Builder protected Apache(String componentVersion,Credential adminCredential,ContainerCapability host,EndpointCapability databaseEndpoint,AdminEndpointCapability adminEndpoint,String nodeName,StandardLifecycle lifecycle,String description){
  super(componentVersion,adminCredential,host,databaseEndpoint,adminEndpoint,nodeName,lifecycle,description);
}
Program: 174144
Project: 174144
Buggy source:
/** 
 * @param nodeName      {@link #nodeName}
 * @param adminEndpoint {@link #adminEndpoint}
 * @param scalable      {@link #scalable}
 * @param binding       {@link #binding}
 * @param localStorage  {@link #localStorage}
 */
public ComputeBuilder builder(String nodeName,AdminEndpointCapability adminEndpoint,ScalableCapability scalable,BindableCapability binding,Requirement<AttachmentCapability,BlockStorage,AttachesTo> localStorage){
  return new ComputeBuilder().nodeName(nodeName).adminEndpoint(adminEndpoint).scalable(scalable).binding(binding).localStorage(localStorage);
}

Fixed version (ground truth):
/** 
 * @param nodeName      {@link #nodeName}
 * @param adminEndpoint {@link #adminEndpoint}
 * @param scalable      {@link #scalable}
 * @param binding       {@link #binding}
 * @param localStorage  {@link #localStorage}
 */
public static ComputeBuilder builder(String nodeName,AdminEndpointCapability adminEndpoint,ScalableCapability scalable,BindableCapability binding,Requirement<AttachmentCapability,BlockStorage,AttachesTo> localStorage){
  return new ComputeBuilder().nodeName(nodeName).adminEndpoint(adminEndpoint).scalable(scalable).binding(binding).localStorage(localStorage);
}
Program: 174145
Project: 174145
Buggy source:
/** 
 * @param mountPoint {@link #mountPoint}
 */
public static AttachesToBuilder builder(String mountPoint){
  return new AttachesToBuilder();
}

Fixed version (ground truth):
/** 
 * @param mountPoint {@link #mountPoint}
 */
public static AttachesToBuilder builder(String mountPoint){
  return new AttachesToBuilder().mountPoint(mountPoint);
}
Program: 174146
Project: 174146
Buggy source:
protected AttachesTo(String mountPoint,String device,String description){
  super(description);
  this.mountPoint=Objects.requireNonNull(mountPoint);
  this.device=device;
}

Fixed version (ground truth):
@Builder protected AttachesTo(String mountPoint,String device,String description){
  super(description);
  this.mountPoint=Objects.requireNonNull(mountPoint);
  this.device=device;
}
Program: 174147
Project: 174147
Buggy source:
/** 
 * Lists all Supported Platforms (HTTP Response Method). <p>  It handles the <code>/platforms</code> Request <p> Always responds with HTTP-Code 200 (application/hal+json)
 */
@RequestMapping(path="String_Node_Str",method=RequestMethod.GET,produces="String_Node_Str") public ResponseEntity<ResourceSupport> getPlatforms(){
  Link selfLink=linkTo(methodOn(PlatformController.class).getPlatforms()).withSelfRel();
  ArrayList<PlatformResponse> responses=new ArrayList<>();
  for (  Platform platform : platformService.getSupportedPlatforms()) {
    log.info("String_Node_Str",platform.id);
    PlatformResponse res=getPlatformResource(platform);
    responses.add(res);
  }
  Resources<PlatformResponse> resources=new Resources<>(responses,selfLink);
  return ResponseEntity.ok(resources);
}

Fixed version (ground truth):
/** 
 * Lists all Supported Platforms (HTTP Response Method). <p> It handles the <code>/platforms</code> Request <p> Always responds with HTTP-Code 200 (application/hal+json)
 */
@RequestMapping(path="String_Node_Str",method=RequestMethod.GET,produces="String_Node_Str") public ResponseEntity<ResourceSupport> getPlatforms(){
  Link selfLink=linkTo(methodOn(PlatformController.class).getPlatforms()).withSelfRel();
  ArrayList<PlatformResponse> responses=new ArrayList<>();
  for (  Platform platform : platformService.getSupportedPlatforms()) {
    log.info("String_Node_Str",platform.id);
    PlatformResponse res=getPlatformResource(platform);
    responses.add(res);
  }
  Resources<PlatformResponse> resources=new Resources<>(responses,selfLink);
  return ResponseEntity.ok(resources);
}
Program: 174148
Project: 174148
Buggy source:
/** 
 * Returns the information for a specific platform. <p>  This method handles the <code>/platforms/{id}</code> request <p> jResponds with Http code 200 normally (application/hal+json) and with code 404 (application/hal+json, standard error message) if the platform with the given name (case sensitive) does not exist.
 * @param id the <code>id</code> (identifier) of the platform (HTTP Path Parameter)
 */
@RequestMapping(path="String_Node_Str",method=RequestMethod.GET,produces="String_Node_Str") public ResponseEntity<PlatformResponse> getPlatform(@PathVariable(name="String_Node_Str") String id){
  Platform p=platformService.findPlatformById(id);
  if (p == null) {
    throw new PlatformNotFoundException();
  }
  return ResponseEntity.ok(getPlatformResource(p));
}

Fixed version (ground truth):
/** 
 * Returns the information for a specific platform. <p> This method handles the <code>/platforms/{id}</code> request <p> jResponds with Http code 200 normally (application/hal+json) and with code 404 (application/hal+json, standard error message) if the platform with the given name (case sensitive) does not exist.
 * @param id the <code>id</code> (identifier) of the platform (HTTP Path Parameter)
 */
@RequestMapping(path="String_Node_Str",method=RequestMethod.GET,produces="String_Node_Str") public ResponseEntity<PlatformResponse> getPlatform(@PathVariable(name="String_Node_Str") String id){
  Platform p=platformService.findPlatformById(id);
  if (p == null) {
    throw new PlatformNotFoundException();
  }
  return ResponseEntity.ok(getPlatformResource(p));
}
Program: 174149
Project: 174149
Buggy source:
private Log getLog(Csar csar,Platform platform){
  File logFile=new File(getRootDir(csar,platform),"String_Node_Str".format(csar.getIdentifier(),platform.id));
  return new LogImpl(logFile);
}

Fixed version (ground truth):
private Log getLog(Csar csar,Platform platform){
  File logFile=new File(getRootDir(csar,platform),format("String_Node_Str",csar.getIdentifier(),platform.id));
  return new LogImpl(logFile);
}
Program: 174150
Project: 174150
Buggy source:
@Override public String toString(){
  return "String_Node_Str".format(csar.getIdentifier(),targetPlatform.id);
}

Fixed version (ground truth):
@Override public String toString(){
  return format("String_Node_Str",csar.getIdentifier(),targetPlatform.id);
}
Program: 174151
Project: 174151
Buggy source:
void setIndex(long index){
  this.index=index;
}

Fixed version (ground truth):
public void setIndex(long index){
  this.index=index;
}
Program: 174152
Project: 174152
Buggy source:
/** 
 * Constructs a LogEntry instance from a log line
 * @param line      the log line which gets parsed
 * @param predecessor the LogEntry preceding this newly created LogEntry
 */
LogEntry(String line,LogEntry predecessor) throws LogParserException {
  if (isRegularLine(line)) {
    parseRegularLine(line,predecessor);
  }
 else {
    parseStackTraceLine(line,predecessor);
  }
}

Fixed version (ground truth):
/** 
 * Constructs a LogEntry instance from a log line
 * @param line        the log line which gets parsed
 * @param predecessor the LogEntry preceding this newly created LogEntry
 */
LogEntry(String line,LogEntry predecessor) throws LogParserException {
  if (isRegularLine(line)) {
    parseRegularLine(line,predecessor);
  }
 else {
    parseStackTraceLine(line,predecessor);
  }
}
Program: 174153
Project: 174153
Buggy source:
/** 
 * Sets the value of the property with its given key. 
 * @throws IllegalArgumentException if a property with given key cannot be found or if the entered value is invalid
 */
public void setPropertyValue(String key,String value){
  setPropertyInternal(key,value);
  if (allRequiredPropertiesSet() && transformation.getState() == TransformationState.INPUT_REQUIRED) {
    transformation.setState(TransformationState.READY);
  }
}

Fixed version (ground truth):
/** 
 * Sets the value of the property with its given key.
 * @throws IllegalArgumentException if a property with given key cannot be found or if the entered value is invalid
 */
public void setPropertyValue(String key,String value){
  setPropertyInternal(key,value);
  if (allRequiredPropertiesSet() && transformation.getState() == TransformationState.INPUT_REQUIRED) {
    transformation.setState(TransformationState.READY);
  }
}
Program: 174154
Project: 174154
Buggy source:
/** 
 * Creates a new property instance with no set property values for the given list (set) of properties.
 * @param properties the set of properties to create a property instance for.Is not allowed to be null,  if no props are needed add a empty set
 */
public PropertyInstance(Set<Property> properties,Transformation transformation){
  this.propertyValues=new HashMap<>();
  this.properties=properties;
  this.transformation=transformation;
  if (properties.stream().anyMatch(Property::isRequired)) {
    transformation.setState(TransformationState.INPUT_REQUIRED);
  }
}

Fixed version (ground truth):
/** 
 * Creates a new property instance with no set property values for the given list (set) of properties.
 * @param properties the set of properties to create a property instance for.Is not allowed to be null, if no props are needed add a empty set
 */
public PropertyInstance(Set<Property> properties,Transformation transformation){
  this.propertyValues=new HashMap<>();
  this.properties=properties;
  this.transformation=transformation;
  if (properties.stream().anyMatch(Property::isRequired)) {
    transformation.setState(TransformationState.INPUT_REQUIRED);
  }
}
Program: 174155
Project: 174155
Buggy source:
@PostConstruct @SuppressWarnings("String_Node_Str") private void initTmpdir(){
  tmpdir=preferences.getDataDir();
}

Fixed version (ground truth):
/** 
 * temp data dir. if files need to get written to disk, use this as root directory. This folder is reset after every test method. Appropriate disk cleanup is performed automatically.
 */
@PostConstruct private void initTmpdir(){
  tmpdir=preferences.getDataDir();
}
Program: 174156
Project: 174156
Buggy source:
@Test public void createTransformation() throws Exception {
  assertTrue(csarService.getCsar(VALID_CSAR_NAME).getTransformations().entrySet().size() == 0);
  mvc.perform(put(CREATE_CSAR_VALID_URL)).andDo(print()).andExpect(status().is(200)).andExpect(content().bytes(new byte[0])).andReturn();
  assertTrue(csarService.getCsar(VALID_CSAR_NAME).getTransformations().entrySet().size() == 1);
  assertTrue(csarService.getCsar(VALID_CSAR_NAME).getTransformations().get(VALID_PLATFORM_NAME) != null);
}

Fixed version (ground truth):
@Test public void createTransformation() throws Exception {
  assertTrue(csarService.getCsar(VALID_CSAR_NAME).getTransformations().entrySet().size() == 0);
  mvc.perform(put(CREATE_CSAR_VALID_URL)).andDo(print()).andExpect(status().is(200)).andExpect(content().bytes(new byte[0])).andReturn();
  assertEquals(1,csarService.getCsar(VALID_CSAR_NAME).getTransformations().entrySet().size());
  assertNotNull(csarService.getCsar(VALID_CSAR_NAME).getTransformations().get(VALID_PLATFORM_NAME));
}
Program: 174157
Project: 174157
Buggy source:
@Override public void deleteCsar(Csar csar){
}

Fixed version (ground truth):
@Override public void deleteCsar(Csar csar){
  csars.remove(csar);
}
Program: 174158
Project: 174158
Buggy source:
@After public void tearDown() throws Exception {
  springThread.stop();
  springThread.join();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @After public void tearDown() throws Exception {
  springThread.stop();
  springThread.join();
}
Program: 174159
Project: 174159
Buggy source:
public static void writeTo(InputStream csarStream,OutputStream fout) throws IOException {
  byte[] data=new byte[512];
  int bytesRead=0;
  while (bytesRead != -1) {
    bytesRead=csarStream.read(data);
    if (bytesRead != -1) {
      fout.write(data,0,bytesRead);
    }
  }
  csarStream.close();
  fout.close();
}

Fixed version (ground truth):
private void writeTo(InputStream csarStream,OutputStream fout) throws IOException {
  byte[] data=new byte[512];
  int bytesRead=0;
  while (bytesRead != -1) {
    bytesRead=csarStream.read(data);
    if (bytesRead != -1) {
      fout.write(data,0,bytesRead);
    }
  }
  csarStream.close();
  fout.close();
}
Program: 174160
Project: 174160
Buggy source:
@Test public void startTransformationInvalidState() throws Exception {
  Transformation t=service.createTransformation(csar,TestPlugins.PLATFORM1);
  t.setState(TransformationState.ERROR);
  assertTrue(!service.startTransformation(t));
}

Fixed version (ground truth):
@Test public void startTransformationInvalidState() throws Exception {
  Transformation t=service.createTransformation(csar,TestPlugins.PLATFORM1);
  t.setState(TransformationState.ERROR);
  assertFalse(service.startTransformation(t));
}
Program: 174161
Project: 174161
Buggy source:
@Test public void startTransformationPropertiesNotSet() throws Exception {
  DummyCsar csar=new DummyCsar("String_Node_Str");
  csar.modelSpecificProperties=new HashSet<>();
  csar.modelSpecificProperties.add(new Property("String_Node_Str",PropertyType.TEXT));
  Transformation t=service.createTransformation(csar,passingDummy.getPlatform());
  assertTrue(!service.startTransformation(t));
}

Fixed version (ground truth):
@Test public void startTransformationPropertiesNotSet() throws Exception {
  DummyCsar csar=new DummyCsar("String_Node_Str");
  csar.modelSpecificProperties=new HashSet<>();
  csar.modelSpecificProperties.add(new Property("String_Node_Str",PropertyType.TEXT));
  Transformation t=service.createTransformation(csar,passingDummy.getPlatform());
  assertFalse(service.startTransformation(t));
}
Program: 174162
Project: 174162
Buggy source:
public void loadAnnotation(WebFilter wf){
  EnumSet<DispatcherType> dispatcherTypes=EnumSet.copyOf(Arrays.asList(wf.dispatcherTypes()));
  this.addMappingForUrlPatterns(dispatcherTypes,true,wf.value());
  this.addMappingForUrlPatterns(dispatcherTypes,true,wf.urlPatterns());
  this.addMappingForServletNames(dispatcherTypes,true,wf.servletNames());
  this.setAsyncSupported(wf.asyncSupported());
  for (  WebInitParam initParam : wf.initParams()) {
    this.setInitParameter(initParam.name(),initParam.value());
  }
}

Fixed version (ground truth):
public void loadAnnotation(WebFilter wf){
  EnumSet<DispatcherType> dispatcherTypes;
  if (wf.dispatcherTypes().length > 0) {
    dispatcherTypes=EnumSet.copyOf(Arrays.asList(wf.dispatcherTypes()));
  }
 else {
    dispatcherTypes=EnumSet.allOf(DispatcherType.class);
  }
  this.addMappingForUrlPatterns(dispatcherTypes,true,wf.value());
  this.addMappingForUrlPatterns(dispatcherTypes,true,wf.urlPatterns());
  this.addMappingForServletNames(dispatcherTypes,true,wf.servletNames());
  this.setAsyncSupported(wf.asyncSupported());
  for (  WebInitParam initParam : wf.initParams()) {
    this.setInitParameter(initParam.name(),initParam.value());
  }
}
Program: 174163
Project: 174163
Buggy source:
public Filter getFilterInstance(){
  if (!this.init) {
    if (((GenericFilter)this.instance).getFilterConfig() != null) {
      this.init=true;
    }
 else synchronized (this) {
      if (!this.init) {
        log.info("String_Node_Str",this.name,this.instance.getClass().getName());
        FilterConfig config=new FilterConfig(){
          @Override public String getFilterName(){
            return TPFilterRegistration.this.name;
          }
          @Override public ServletContext getServletContext(){
            return TPFilterRegistration.this.context;
          }
          @Override public String getInitParameter(          String name){
            return TPFilterRegistration.this.getInitParameter(name);
          }
          @Override public Enumeration<String> getInitParameterNames(){
            return Collections.enumeration(TPFilterRegistration.this.getInitParameters().keySet());
          }
        }
;
        try {
          this.instance.init(config);
          this.init=true;
        }
 catch (        ServletException e) {
          log.error("String_Node_Str",this.name,this.instance.getClass().getName(),e);
        }
      }
    }
  }
  return this.instance;
}

Fixed version (ground truth):
public Filter getFilterInstance(){
  if (!this.init) {
    if ((this.instance instanceof GenericFilter) && (((GenericFilter)this.instance).getFilterConfig() != null)) {
      this.init=true;
    }
 else synchronized (this) {
      if (!this.init) {
        log.info("String_Node_Str",this.name,this.instance.getClass().getName());
        FilterConfig config=new FilterConfig(){
          @Override public String getFilterName(){
            return TPFilterRegistration.this.name;
          }
          @Override public ServletContext getServletContext(){
            return TPFilterRegistration.this.context;
          }
          @Override public String getInitParameter(          String name){
            return TPFilterRegistration.this.getInitParameter(name);
          }
          @Override public Enumeration<String> getInitParameterNames(){
            return Collections.enumeration(TPFilterRegistration.this.getInitParameters().keySet());
          }
        }
;
        try {
          this.instance.init(config);
          this.init=true;
        }
 catch (        ServletException e) {
          log.error("String_Node_Str",this.name,this.instance.getClass().getName(),e);
        }
      }
    }
  }
  return this.instance;
}
Program: 174164
Project: 174164
Buggy source:
private static void ensureInit(){
  if (!init) {
synchronized (BeanPopulators.class) {
      if (!init) {
        init=true;
        log.info("String_Node_Str");
        ScanResult result=AutumnClasspathScan.getScanResult();
        result.getNamesOfSubclassesOf(AnnotatedFieldPopulator.class).forEach(cn -> {
          try {
            AnnotatedFieldPopulator<?> populator=(AnnotatedFieldPopulator<?>)result.classNameToClassRef(cn).newInstance();
            annotatedFieldPopulatorMap.put(populator.getAnnotationClass(),populator);
          }
 catch (          Exception e) {
            log.warn("String_Node_Str" + cn + "String_Node_Str"+ e);
          }
        }
);
      }
    }
  }
}

Fixed version (ground truth):
private static void ensureInit(){
  if (!init) {
synchronized (BeanPopulators.class) {
      if (!init) {
        log.info("String_Node_Str");
        ScanResult result=AutumnClasspathScan.getScanResult();
        result.getNamesOfSubclassesOf(AnnotatedFieldPopulator.class).forEach(cn -> {
          try {
            AnnotatedFieldPopulator<?> populator=(AnnotatedFieldPopulator<?>)result.classNameToClassRef(cn).newInstance();
            annotatedFieldPopulatorMap.put(populator.getAnnotationClass(),populator);
          }
 catch (          Exception e) {
            log.warn("String_Node_Str" + cn + "String_Node_Str"+ e);
          }
        }
);
        init=true;
      }
    }
  }
}
Program: 174165
Project: 174165
Buggy source:
private static void ensureInit(){
  if (!init) {
synchronized (BeanProcessors.class) {
      if (!init) {
        init=true;
        log.info("String_Node_Str");
        ScanResult result=AutumnClasspathScan.getScanResult();
        result.getNamesOfClassesImplementing(BeanProcessor.class).forEach(cn -> {
          try {
            Class<? extends BeanProcessor> processorClass=(Class<? extends BeanProcessor>)result.classNameToClassRef(cn);
            BeanProcessor processor=processorClass.newInstance();
            for (            Class<?> intf : processorClass.getInterfaces()) {
              if (BeanProcessor.class.isAssignableFrom(intf)) {
                beanProcessors.computeIfAbsent((Class<? extends BeanProcessor>)intf,x -> new ArrayList<>()).add(processor);
              }
            }
          }
 catch (          Exception e) {
            log.warn("String_Node_Str" + cn + "String_Node_Str"+ e);
          }
        }
);
      }
    }
  }
}

Fixed version (ground truth):
private static void ensureInit(){
  if (!init) {
synchronized (BeanProcessors.class) {
      if (!init) {
        log.info("String_Node_Str");
        ScanResult result=AutumnClasspathScan.getScanResult();
        result.getNamesOfClassesImplementing(BeanProcessor.class).forEach(cn -> {
          try {
            Class<? extends BeanProcessor> processorClass=(Class<? extends BeanProcessor>)result.classNameToClassRef(cn);
            BeanProcessor processor=processorClass.newInstance();
            for (            Class<?> intf : processorClass.getInterfaces()) {
              if (BeanProcessor.class.isAssignableFrom(intf)) {
                beanProcessors.computeIfAbsent((Class<? extends BeanProcessor>)intf,x -> new ArrayList<>()).add(processor);
              }
            }
          }
 catch (          Exception e) {
            log.warn("String_Node_Str" + cn + "String_Node_Str"+ e);
          }
        }
);
        init=true;
      }
    }
  }
}
Program: 174166
Project: 174166
Buggy source:
void register(AbstractSelectableChannel channel,int op,Object attachment){
  regLock.lock();
  try {
    selector.wakeup();
    channel.register(selector,op,attachment);
  }
 catch (  ClosedChannelException e) {
    log.warn("String_Node_Str",e);
  }
  regLock.unlock();
}

Fixed version (ground truth):
void register(AbstractSelectableChannel channel,int op,Object attachment){
  regLock.lock();
  try {
    selector.wakeup();
    channel.register(selector,op,attachment);
  }
 catch (  ClosedChannelException e) {
    log.warn("String_Node_Str",e);
  }
 finally {
    regLock.unlock();
  }
}
Program: 174167
Project: 174167
Buggy source:
private static void ensureInit(){
  if (!init) {
synchronized (MethodParamsResolver.class) {
      if (!init) {
        init=true;
        log.info("String_Node_Str");
        ScanResult result=AutumnClasspathScan.getScanResult();
        result.getNamesOfSubclassesOf(AnnotatedParamResolver.class).forEach(cn -> {
          try {
            AnnotatedParamResolver<?> resolver=(AnnotatedParamResolver<?>)result.classNameToClassRef(cn).newInstance();
            annotatedResolvers.put(resolver.getAnnotationClass(),resolver);
          }
 catch (          Exception ignored) {
          }
        }
);
        result.getNamesOfSubclassesOf(TypedParamResolver.class).forEach(cn -> {
          try {
            typedResolvers.add((TypedParamResolver<?>)result.classNameToClassRef(cn).newInstance());
          }
 catch (          Exception ignored) {
          }
        }
);
        result.getNamesOfClassesImplementing(ParamConverter.class).forEach(cn -> {
          try {
            ParamConverter converter=(ParamConverter)result.classNameToClassRef(cn).newInstance();
            for (            Class targetType : converter.getTargetTypes()) {
              typeConverters.put(targetType,converter);
            }
          }
 catch (          Exception e) {
            e.printStackTrace();
          }
        }
);
      }
    }
  }
}

Fixed version (ground truth):
private static void ensureInit(){
  if (!init) {
synchronized (MethodParamsResolver.class) {
      if (!init) {
        log.info("String_Node_Str");
        ScanResult result=AutumnClasspathScan.getScanResult();
        result.getNamesOfSubclassesOf(AnnotatedParamResolver.class).forEach(cn -> {
          try {
            AnnotatedParamResolver<?> resolver=(AnnotatedParamResolver<?>)result.classNameToClassRef(cn).newInstance();
            annotatedResolvers.put(resolver.getAnnotationClass(),resolver);
          }
 catch (          Exception ignored) {
          }
        }
);
        result.getNamesOfSubclassesOf(TypedParamResolver.class).forEach(cn -> {
          try {
            typedResolvers.add((TypedParamResolver<?>)result.classNameToClassRef(cn).newInstance());
          }
 catch (          Exception ignored) {
          }
        }
);
        result.getNamesOfClassesImplementing(ParamConverter.class).forEach(cn -> {
          try {
            ParamConverter converter=(ParamConverter)result.classNameToClassRef(cn).newInstance();
            for (            Class targetType : converter.getTargetTypes()) {
              typeConverters.put(targetType,converter);
            }
          }
 catch (          Exception e) {
            e.printStackTrace();
          }
        }
);
        init=true;
      }
    }
  }
}
Program: 174168
Project: 174168
Buggy source:
@Override public Object createBean() throws BeanCreationException {
  SqlSessionFactory sqlSessionFactory=(SqlSessionFactory)context.getBeanByType(SqlSessionFactory.class);
  if (sqlSessionFactory == null) {
    throw new BeanCreationException("String_Node_Str");
  }
  try {
    return sqlSessionFactory.openSession().getMapper(mapperType);
  }
 catch (  Exception e) {
    throw new BeanCreationException(e);
  }
}

Fixed version (ground truth):
@Override public Object createBean() throws BeanCreationException {
  SqlSessionFactory sqlSessionFactory=(SqlSessionFactory)context.getBeanByType(SqlSessionFactory.class);
  if (sqlSessionFactory == null) {
    throw new BeanCreationException("String_Node_Str");
  }
  try {
    return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class<?>[]{mapperType},new InvocationHandler(){
      private ThreadLocal<Object> targetLocal=new ThreadLocal<>();
      @Override public Object invoke(      Object proxy,      Method method,      Object[] args) throws Throwable {
        Object target=targetLocal.get();
        if (target == null) {
          target=sqlSessionFactory.openSession(true).getMapper(mapperType);
          targetLocal.set(target);
        }
        try {
          return method.invoke(target,args);
        }
 catch (        InvocationTargetException e) {
          throw e.getTargetException();
        }
      }
    }
);
  }
 catch (  Exception e) {
    throw new BeanCreationException(e);
  }
}
Program: 174170
Project: 174170
Buggy source:
public String nextLine(){
  while (pos < offset + limit - 1) {
    if (src[pos] == '\r' && src[pos + 1] == '\n') {
      String line=new String(src,lineStart,pos - lineStart);
      pos+=2;
      lineStart=pos;
      return line;
    }
    pos++;
  }
  if (pos < offset + limit) {
    pos++;
    return new String(src,lineStart,pos - lineStart);
  }
  return null;
}

Fixed version (ground truth):
public String nextLine(){
  while (pos < offset + limit - 1) {
    if (src[pos] == '\r' && src[pos + 1] == '\n') {
      String line=new String(src,lineStart,pos - lineStart);
      pos+=2;
      lineStart=pos;
      return line;
    }
    pos++;
  }
  return null;
}
Program: 174171
Project: 174171
Buggy source:
public <T>T getService(Class<T> interfaze,int timeout){
  return proxy.create(interfaze,(proxy,method,args) -> {
    String url="String_Node_Str" + host + "String_Node_Str"+ port+ "String_Node_Str"+ interfaze.getName();
    AutumnRPCRequest request=AutumnRPCRequest.builder().methodName(method.getName()).paramTypes(method.getParameterTypes()).params(args).build();
    byte[] payload=serialization.serializeRequest(request);
    byte[] response=httpClient.post(url,payload,serialization.contentType(),timeout);
    AutumnRPCResponse rpcResponse=serialization.deserializeResponse(response,method.getReturnType());
    if (rpcResponse.getStatus() == STATUS_OK) {
      return serialization.convertTypes(new Object[]{rpcResponse.getResult()},new Type[]{method.getGenericReturnType()})[0];
    }
 else {
      throw (Throwable)rpcResponse.getResult();
    }
  }
);
}

Fixed version (ground truth):
public <T>T getService(Class<T> interfaze,int timeout){
  return proxy.create(interfaze,(proxy,method,args) -> {
    String url="String_Node_Str" + host + "String_Node_Str"+ port+ "String_Node_Str"+ interfaze.getName();
    AutumnRPCRequest request=AutumnRPCRequest.builder().methodName(method.getName()).paramTypes(method.getParameterTypes()).params(args).build();
    byte[] payload=serialization.serializeRequest(request);
    byte[] response=httpClient.post(url,payload,serialization.contentType(),timeout);
    Class<?> returnType=method.getReturnType();
    AutumnRPCResponse rpcResponse=serialization.deserializeResponse(response,returnType);
    if (rpcResponse.getStatus() == STATUS_OK) {
      if (returnType == void.class || returnType == Void.class) {
        return null;
      }
      return serialization.convertTypes(new Object[]{rpcResponse.getResult()},new Type[]{method.getGenericReturnType()})[0];
    }
 else {
      throw (Throwable)rpcResponse.getResult();
    }
  }
);
}
Program: 174172
Project: 174172
Buggy source:
private Object convertParam(Parameter param,ParamValue value) throws ParamConvertException {
  Class<?> paramType=param.getType();
  if (paramType.isInstance(value.getSingleValue())) {
    return value.getSingleValue();
  }
  if (paramType.isInstance(value.getMultipleValues())) {
    return value.getMultipleValues();
  }
  boolean needMultipleValues=paramType.isArray() || Collection.class.isAssignableFrom(paramType);
  Object rawValue=needMultipleValues ? value.getMultipleValues() : value.getSingleValue();
  if (rawValue != null) {
    try {
      if (needMultipleValues) {
        Collection valueCollection=((Collection)rawValue);
        if (paramType.isArray()) {
          Class<?> innerType=paramType.getComponentType();
          return convertMultiple(valueCollection,innerType);
        }
 else {
          Type type=param.getParameterizedType();
          if (type instanceof ParameterizedType) {
            Type innerType=((ParameterizedType)type).getActualTypeArguments()[0];
            if (innerType instanceof Class) {
              valueCollection=Arrays.asList((Object[])convertMultiple(valueCollection,(Class<?>)innerType));
            }
          }
          return collectionConverter.convert(valueCollection,(Class<?>)paramType);
        }
      }
 else {
        return convertSingle(rawValue,paramType);
      }
    }
 catch (    ParamConvertException e) {
      return convertFromJson(param,value);
    }
  }
  return null;
}

Fixed version (ground truth):
private Object convertParam(Parameter param,ParamValue value) throws ParamConvertException {
  Class<?> paramType=param.getType();
  if (paramType.isInstance(value.getSingleValue())) {
    return value.getSingleValue();
  }
  boolean needMultipleValues=paramType.isArray() || Collection.class.isAssignableFrom(paramType);
  Object rawValue=needMultipleValues ? value.getMultipleValues() : value.getSingleValue();
  if (rawValue != null) {
    try {
      if (needMultipleValues) {
        Collection valueCollection=((Collection)rawValue);
        if (paramType.isArray()) {
          Class<?> innerType=paramType.getComponentType();
          return convertMultiple(valueCollection,innerType);
        }
 else {
          Type type=param.getParameterizedType();
          if (type instanceof ParameterizedType) {
            Type innerType=((ParameterizedType)type).getActualTypeArguments()[0];
            if (innerType instanceof Class) {
              valueCollection=Arrays.asList((Object[])convertMultiple(valueCollection,(Class<?>)innerType));
            }
          }
          return collectionConverter.convert(valueCollection,(Class<?>)paramType);
        }
      }
 else {
        return convertSingle(rawValue,paramType);
      }
    }
 catch (    ParamConvertException e) {
      try {
        return convertFromJson(param,value);
      }
 catch (      ParamConvertException e1) {
        throw new ParamConvertException("String_Node_Str" + param + "String_Node_Str");
      }
    }
  }
  return null;
}
Program: 174173
Project: 174173
Buggy source:
@Override protected void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  RequestMappingModel mapping=restContext.matchRequest(req);
  if (mapping == null || mapping.getMethod() == null) {
    resp.sendError(404);
    return;
  }
  Method method=mapping.getMethod();
  String produces=mapping.getProduces();
  if (produces.isEmpty()) {
    produces="String_Node_Str";
  }
  try {
    Object[] params=paramsResolver.resolveAll(method,req,resp);
    String result=String.valueOf(method.invoke(getInstance(method.getDeclaringClass()),params));
    resp.setContentType(produces);
    resp.getOutputStream().print(result);
  }
 catch (  IllegalAccessException|InvocationTargetException e) {
    log.error("String_Node_Str" + method + "String_Node_Str"+ e);
  }
catch (  ParamResolveException e) {
    throw new ServletException(e);
  }
}

Fixed version (ground truth):
@Override protected void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  RequestMappingModel mapping=restContext.matchRequest(req);
  if (mapping == null || mapping.getMethod() == null) {
    resp.sendError(404);
    return;
  }
  Method method=mapping.getMethod();
  String produces=mapping.getProduces();
  if (produces.isEmpty()) {
    produces="String_Node_Str";
  }
  try {
    Object[] params=paramsResolver.resolveAll(method,req,resp);
    String result=String.valueOf(method.invoke(getInstance(method.getDeclaringClass()),params));
    resp.setContentType(produces);
    resp.getOutputStream().print(result);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + method + "String_Node_Str"+ e);
    throw new ServletException(e);
  }
}