nus-yam/ex-repair huggingface dataset:
Program: 72571
Project: 72571
Buggy source:
/** 
 * Test the migrateModels() method in the case when the given path is correct and it contains models at the first level and models inside a directory which is inside the current directory but we want to only migrate those in the first level.
 * @exception Exception Thrown by PowerMock if error occurs in the testing.
 */
@Test public void testMigrateModelsNoDepth_checkContent() throws Exception {
  String directoryPath=createDirectory(2,2);
  MigrateModelsManager migrateModelsManager=new MigrateModelsManager();
  try {
    String csvFilePath=migrateModelsManager.migrateModels(directoryPath,false,true);
    assertTrue(csvFilePath.equals(directoryPath + System.getProperty("String_Node_Str") + "String_Node_Str"));
    File csvFile=new File(csvFilePath);
    BufferedReader input=new BufferedReader(new FileReader(csvFile));
    try {
      int count=0;
      String line="String_Node_Str";
      while (input.readLine() != null) {
        if (line.length() > 10) {
          count++;
        }
      }
      assertTrue(count == 3);
    }
  finally {
      input.close();
    }
    PowerMock.verifyAll();
  }
 catch (  IOException e) {
    fail("String_Node_Str" + e.getMessage());
  }
 finally {
    _cleanup(directoryPath);
  }
}

Fixed version (ground truth):
/** 
 * Test the migrateModels() method in the case when the given path is correct and it contains models at the first level and models inside a directory which is inside the current directory but we want to only migrate those in the first level.
 * @exception Exception Thrown by PowerMock if error occurs in the testing.
 */
@Test public void testMigrateModelsNoDepth_checkContent() throws Exception {
  String directoryPath=createDirectory(2,2);
  MigrateModelsManager migrateModelsManager=new MigrateModelsManager();
  try {
    String csvFilePath=migrateModelsManager.migrateModels(directoryPath,false,true);
    assertTrue(csvFilePath.equals(directoryPath + System.getProperty("String_Node_Str") + "String_Node_Str"));
    File csvFile=new File(csvFilePath);
    BufferedReader input=new BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(csvFile),java.nio.charset.Charset.defaultCharset()));
    try {
      int count=0;
      String line="String_Node_Str";
      while (input.readLine() != null) {
        if (line.length() > 10) {
          count++;
        }
      }
      assertTrue(count == 3);
    }
  finally {
      input.close();
    }
    PowerMock.verifyAll();
  }
 catch (  IOException e) {
    fail("String_Node_Str" + e.getMessage());
  }
 finally {
    _cleanup(directoryPath);
  }
}
Program: 72572
Project: 72572
Buggy source:
/** 
 * Test the migrateModels() method in the case when the given path is correct and it contains models at the first level and models inside a directory which is inside the current directory but we want to only migrate those in the first level.
 * @exception Exception Thrown by PowerMock if error occurs in the testing.
 */
@Test public void testMigrateModelsNoDepth_NoCheckContent() throws Exception {
  String directoryPath=createDirectory(2,2);
  MigrateModelsManager migrateModelsManager=new MigrateModelsManager();
  try {
    String csvFilePath=migrateModelsManager.migrateModels(directoryPath,false,false);
    assertTrue(csvFilePath.equals(directoryPath + System.getProperty("String_Node_Str") + "String_Node_Str"));
    File csvFile=new File(csvFilePath);
    BufferedReader input=new BufferedReader(new FileReader(csvFile));
    try {
      int count=0;
      String line="String_Node_Str";
      while (input.readLine() != null) {
        if (line.length() > 10) {
          count++;
        }
      }
      assertTrue(count == 3);
    }
  finally {
      input.close();
    }
    PowerMock.verifyAll();
  }
 catch (  IOException e) {
    fail("String_Node_Str" + e.getMessage());
  }
 finally {
    _cleanup(directoryPath);
  }
}

Fixed version (ground truth):
/** 
 * Test the migrateModels() method in the case when the given path is correct and it contains models at the first level and models inside a directory which is inside the current directory but we want to only migrate those in the first level.
 * @exception Exception Thrown by PowerMock if error occurs in the testing.
 */
@Test public void testMigrateModelsNoDepth_NoCheckContent() throws Exception {
  String directoryPath=createDirectory(2,2);
  MigrateModelsManager migrateModelsManager=new MigrateModelsManager();
  try {
    String csvFilePath=migrateModelsManager.migrateModels(directoryPath,false,false);
    assertTrue(csvFilePath.equals(directoryPath + System.getProperty("String_Node_Str") + "String_Node_Str"));
    File csvFile=new File(csvFilePath);
    BufferedReader input=new BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(csvFile),java.nio.charset.Charset.defaultCharset()));
    try {
      int count=0;
      String line="String_Node_Str";
      while (input.readLine() != null) {
        if (line.length() > 10) {
          count++;
        }
      }
      assertTrue(count == 3);
    }
  finally {
      input.close();
    }
    PowerMock.verifyAll();
  }
 catch (  IOException e) {
    fail("String_Node_Str" + e.getMessage());
  }
 finally {
    _cleanup(directoryPath);
  }
}
Program: 72573
Project: 72573
Buggy source:
/** 
 * Test the migrateModels() method in the case when the given path is correct and it contains models at the first level and models inside a directory which is inside the current directory but we want to only migrate those in the first level.
 * @exception Exception Thrown by PowerMock if error occurs in the testing.
 */
@Test public void testMigrateModelsNoDepth() throws Exception {
  String directoryPath=createDirectory(2,2);
  MigrateModelsManager migrateModelsManager=new MigrateModelsManager();
  try {
    String csvFilePath=migrateModelsManager.migrateModels(directoryPath,false,true);
    assertTrue(csvFilePath.equals(directoryPath + System.getProperty("String_Node_Str") + "String_Node_Str"));
    File csvFile=new File(csvFilePath);
    BufferedReader input=new BufferedReader(new FileReader(csvFile));
    try {
      int count=0;
      String line="String_Node_Str";
      while ((line=input.readLine()) != null) {
        if (line.length() > 10) {
          count++;
        }
      }
      assertTrue(count == 3);
    }
  finally {
      input.close();
    }
    PowerMock.verifyAll();
  }
 catch (  IOException e) {
    fail("String_Node_Str" + e.getMessage());
  }
 finally {
    _cleanup(directoryPath);
  }
}

Fixed version (ground truth):
/** 
 * Test the migrateModels() method in the case when the given path is correct and it contains models at the first level and models inside a directory which is inside the current directory but we want to only migrate those in the first level.
 * @exception Exception Thrown by PowerMock if error occurs in the testing.
 */
@Test public void testMigrateModelsNoDepth() throws Exception {
  String directoryPath=createDirectory(2,2);
  MigrateModelsManager migrateModelsManager=new MigrateModelsManager();
  try {
    String csvFilePath=migrateModelsManager.migrateModels(directoryPath,false,true);
    assertTrue(csvFilePath.equals(directoryPath + System.getProperty("String_Node_Str") + "String_Node_Str"));
    File csvFile=new File(csvFilePath);
    BufferedReader input=new BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(csvFile),java.nio.charset.Charset.defaultCharset()));
    try {
      int count=0;
      String line="String_Node_Str";
      while ((line=input.readLine()) != null) {
        if (line.length() > 10) {
          count++;
        }
      }
      assertTrue(count == 3);
    }
  finally {
      input.close();
    }
    PowerMock.verifyAll();
  }
 catch (  IOException e) {
    fail("String_Node_Str" + e.getMessage());
  }
 finally {
    _cleanup(directoryPath);
  }
}
Program: 72575
Project: 72575
Buggy source:
/** 
 * Read the user input to decide whether the rebuild references process should be started or not.
 * @return The user input.
 * @exception IOException If thrown while reading input from the console.
 */
private static String _readInput() throws IOException {
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  String userInput=null;
  try {
    userInput=br.readLine();
  }
  finally {
    br.close();
  }
  return userInput;
}

Fixed version (ground truth):
/** 
 * Read the user input to decide whether the rebuild references process should be started or not.
 * @return The user input.
 * @exception IOException If thrown while reading input from the console.
 */
private static String _readInput() throws IOException {
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in,java.nio.charset.Charset.defaultCharset()));
  String userInput=null;
  try {
    userInput=br.readLine();
  }
  finally {
    br.close();
  }
  return userInput;
}
Program: 72577
Project: 72577
Buggy source:
/** 
 * Create a _StreamReaderThread.
 * @param inputStream The stream to read from.
 * @param name The name of this StreamReaderThread,which is useful for debugging.
 * @param actor The parent actor of this thread, whichis used in error messages.
 */
_StreamReaderThread(InputStream inputStream,String name,Nameable actor){
  super(name);
  _inputStream=inputStream;
  _inputStreamReader=new InputStreamReader(_inputStream);
  _actor=actor;
  _stringBuffer=new StringBuffer();
}

Fixed version (ground truth):
/** 
 * Create a _StreamReaderThread.
 * @param inputStream The stream to read from.
 * @param name The name of this StreamReaderThread,which is useful for debugging.
 * @param actor The parent actor of this thread, whichis used in error messages.
 */
_StreamReaderThread(InputStream inputStream,String name,Nameable actor){
  super(name);
  _inputStream=inputStream;
  _inputStreamReader=new InputStreamReader(_inputStream,java.nio.charset.Charset.defaultCharset());
  _actor=actor;
  _stringBuffer=new StringBuffer();
}
Program: 72578
Project: 72578
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Reader(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  output.setMultiport(true);
  output.setTypeEquals(BaseType.DOUBLE);
  sourceURL=new Parameter(this,"String_Node_Str",new StringToken("String_Node_Str"));
  sourceURL.setTypeEquals(BaseType.STRING);
  refresh=new Parameter(this,"String_Node_Str",new BooleanToken(false));
  refresh.setTypeEquals(BaseType.BOOLEAN);
  if (_stdIn == null) {
    _stdIn=new BufferedReader(new InputStreamReader(System.in));
  }
  setReader(_stdIn);
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Reader(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  output.setMultiport(true);
  output.setTypeEquals(BaseType.DOUBLE);
  sourceURL=new Parameter(this,"String_Node_Str",new StringToken("String_Node_Str"));
  sourceURL.setTypeEquals(BaseType.STRING);
  refresh=new Parameter(this,"String_Node_Str",new BooleanToken(false));
  refresh.setTypeEquals(BaseType.BOOLEAN);
  if (_stdIn == null) {
    _stdIn=new BufferedReader(new InputStreamReader(System.in,java.nio.charset.Charset.defaultCharset()));
  }
  setReader(_stdIn);
}
Program: 72579
Project: 72579
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public URLReader(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  output.setMultiport(true);
  output.setTypeEquals(BaseType.DOUBLE);
  sourceURL=new Parameter(this,"String_Node_Str",new StringToken("String_Node_Str"));
  sourceURL.setTypeEquals(BaseType.STRING);
  refresh=new Parameter(this,"String_Node_Str",new BooleanToken(false));
  refresh.setTypeEquals(BaseType.BOOLEAN);
  if (_stdIn == null) {
    _stdIn=new BufferedReader(new InputStreamReader(System.in));
  }
  _setURLReader(_stdIn);
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public URLReader(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  output.setMultiport(true);
  output.setTypeEquals(BaseType.DOUBLE);
  sourceURL=new Parameter(this,"String_Node_Str",new StringToken("String_Node_Str"));
  sourceURL.setTypeEquals(BaseType.STRING);
  refresh=new Parameter(this,"String_Node_Str",new BooleanToken(false));
  refresh.setTypeEquals(BaseType.BOOLEAN);
  if (_stdIn == null) {
    _stdIn=new BufferedReader(new InputStreamReader(System.in,java.nio.charset.Charset.defaultCharset()));
  }
  _setURLReader(_stdIn);
}
Program: 72581
Project: 72581
Buggy source:
/** 
 * Create a _StreamReaderThread.
 * @param inputStream The stream to read from.
 * @param name The name of this StreamReaderThread,which is useful for debugging.
 * @param actor The parent actor of this thread, whichis used in error messages.
 */
_StreamReaderThread(InputStream inputStream,String name,Nameable actor){
  super(name);
  _inputStream=inputStream;
  _inputStreamReader=new InputStreamReader(_inputStream);
  _actor=actor;
  _stringBuffer=new StringBuffer();
}

Fixed version (ground truth):
/** 
 * Create a _StreamReaderThread.
 * @param inputStream The stream to read from.
 * @param name The name of this StreamReaderThread,which is useful for debugging.
 * @param actor The parent actor of this thread, whichis used in error messages.
 */
_StreamReaderThread(InputStream inputStream,String name,Nameable actor){
  super(name);
  _inputStream=inputStream;
  _inputStreamReader=new InputStreamReader(_inputStream,java.nio.charset.Charset.defaultCharset());
  _actor=actor;
  _stringBuffer=new StringBuffer();
}
Program: 72582
Project: 72582
Buggy source:
/** 
 * Create a _StreamReaderThread.
 * @param inputStream The stream to read from.
 * @param name The name of this StreamReaderThread,which is useful for debugging.
 * @param actor The parent actor of this thread, whichis used in error messages.
 */
_StreamReaderThread(InputStream inputStream,String name,Nameable actor){
  super(name);
  _inputStream=inputStream;
  _inputStreamReader=new InputStreamReader(_inputStream);
  _actor=actor;
  _stringBuffer=new StringBuffer();
}

Fixed version (ground truth):
/** 
 * Create a _StreamReaderThread.
 * @param inputStream The stream to read from.
 * @param name The name of this StreamReaderThread,which is useful for debugging.
 * @param actor The parent actor of this thread, whichis used in error messages.
 */
_StreamReaderThread(InputStream inputStream,String name,Nameable actor){
  super(name);
  _inputStream=inputStream;
  _inputStreamReader=new InputStreamReader(_inputStream,java.nio.charset.Charset.defaultCharset());
  _actor=actor;
  _stringBuffer=new StringBuffer();
}
Program: 72583
Project: 72583
Buggy source:
/** 
 * Output XML configuration to the pre-defined file (specified with "-config" argument in   {@link #main(String[])}).
 * @exception Exception If any error occurs.
 */
protected static void _outputConfig() throws Exception {
  if (_configName != null) {
    SourceOutputStream stream=SourceOutputStream.getStream(_configName,_overwrite);
    Set<String> classSet=new HashSet<String>();
    classSet.addAll(_classes);
    ConfigParser parser=new ConfigParser();
    parser.addExcludedFile(new File(_configName).getCanonicalPath());
    parser.parseConfigFile(ConfigParser.DEFAULT_SYSTEM_ID,classSet);
    if ((_prefix != null) && (_prefix.length() > 0)) {
      parser.addPackagePrefix(_prefix,classSet);
    }
    OutputStreamWriter writer=null;
    try {
      writer=new OutputStreamWriter(stream);
      XmlOutput.outputXmlTree(parser.getTree(),writer);
    }
  finally {
      if (writer != null) {
        writer.close();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Output XML configuration to the pre-defined file (specified with "-config" argument in   {@link #main(String[])}).
 * @exception Exception If any error occurs.
 */
protected static void _outputConfig() throws Exception {
  if (_configName != null) {
    SourceOutputStream stream=SourceOutputStream.getStream(_configName,_overwrite);
    Set<String> classSet=new HashSet<String>();
    classSet.addAll(_classes);
    ConfigParser parser=new ConfigParser();
    parser.addExcludedFile(new File(_configName).getCanonicalPath());
    parser.parseConfigFile(ConfigParser.DEFAULT_SYSTEM_ID,classSet);
    if ((_prefix != null) && (_prefix.length() > 0)) {
      parser.addPackagePrefix(_prefix,classSet);
    }
    OutputStreamWriter writer=null;
    try {
      writer=new OutputStreamWriter(stream,java.nio.charset.Charset.defaultCharset());
      XmlOutput.outputXmlTree(parser.getTree(),writer);
    }
  finally {
      if (writer != null) {
        writer.close();
      }
    }
  }
}
Program: 72585
Project: 72585
Buggy source:
/** 
 * Parse a configuration file and build the XML tree below the given parent node (or <tt>null</tt> if not given). Only the nodes corresponding to the classes in <tt>includedClasses</tt> and their parent nodes are created. Other nodes in the XML tree are ignored.
 * @param fileName The name of the configuration file.
 * @param includedClasses The set of names of classes to be included.
 * @param backtrackingElement Whether to set the parent node of theconstructed XML tree to be the "backtrack" node.
 * @exception Exception If error occurs.
 */
public void parseConfigFile(String fileName,Set<String> includedClasses,boolean backtrackingElement) throws Exception {
  XmlParser parser=new XmlParser();
  BufferedReader br=new BufferedReader(new FileReader(fileName));
  ConfigXmlHandler handler=new ConfigXmlHandler(_xmlTree,fileName,includedClasses);
  handler.addExcludedFiles(_excludedFiles);
  parser.setHandler(handler);
  try {
    parser.parse(fileName,null,br);
  }
 catch (  Throwable throwable) {
    throw new Exception("String_Node_Str" + fileName + "String_Node_Str",throwable);
  }
  if (backtrackingElement) {
    _xmlTree._setElementName("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Parse a configuration file and build the XML tree below the given parent node (or <tt>null</tt> if not given). Only the nodes corresponding to the classes in <tt>includedClasses</tt> and their parent nodes are created. Other nodes in the XML tree are ignored.
 * @param fileName The name of the configuration file.
 * @param includedClasses The set of names of classes to be included.
 * @param backtrackingElement Whether to set the parent node of theconstructed XML tree to be the "backtrack" node.
 * @exception Exception If error occurs.
 */
public void parseConfigFile(String fileName,Set<String> includedClasses,boolean backtrackingElement) throws Exception {
  XmlParser parser=new XmlParser();
  BufferedReader br=new BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(fileName),java.nio.charset.Charset.defaultCharset()));
  ConfigXmlHandler handler=new ConfigXmlHandler(_xmlTree,fileName,includedClasses);
  handler.addExcludedFiles(_excludedFiles);
  parser.setHandler(handler);
  try {
    parser.parse(fileName,null,br);
  }
 catch (  Throwable throwable) {
    throw new Exception("String_Node_Str" + fileName + "String_Node_Str",throwable);
  }
  if (backtrackingElement) {
    _xmlTree._setElementName("String_Node_Str");
  }
}
Program: 72586
Project: 72586
Buggy source:
/** 
 * Given a string that names a file, URL or resource, try to open as a file, and then as a URL, then as a resource.
 * @param inputFileName The name of the file or URL to open
 * @return A BufferedReader that refers to the inputFileName
 * @exception FileNotFoundException If the file cannot be found.
 * @exception IOException If there were problems creatingthe BufferedReader.
 */
public static BufferedReader openAsFileOrURL(String inputFileName) throws FileNotFoundException, IOException {
  BufferedReader inputFile;
  try {
    inputFile=new BufferedReader(new FileReader(inputFileName));
  }
 catch (  IOException ex) {
    try {
      inputFile=new BufferedReader(new InputStreamReader(new URL(inputFileName).openStream()));
    }
 catch (    Throwable throwable) {
      URL inputFileURL=Thread.currentThread().getContextClassLoader().getResource(inputFileName);
      if (inputFileURL == null) {
        throw ex;
      }
      inputFile=new BufferedReader(new InputStreamReader(inputFileURL.openStream()));
    }
  }
  return inputFile;
}

Fixed version (ground truth):
/** 
 * Given a string that names a file, URL or resource, try to open as a file, and then as a URL, then as a resource.
 * @param inputFileName The name of the file or URL to open
 * @return A BufferedReader that refers to the inputFileName
 * @exception FileNotFoundException If the file cannot be found.
 * @exception IOException If there were problems creatingthe BufferedReader.
 */
public static BufferedReader openAsFileOrURL(String inputFileName) throws FileNotFoundException, IOException {
  BufferedReader inputFile;
  try {
    inputFile=new BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(inputFileName),java.nio.charset.Charset.defaultCharset()));
  }
 catch (  IOException ex) {
    try {
      inputFile=new BufferedReader(new InputStreamReader(new URL(inputFileName).openStream()));
    }
 catch (    Throwable throwable) {
      URL inputFileURL=Thread.currentThread().getContextClassLoader().getResource(inputFileName);
      if (inputFileURL == null) {
        throw ex;
      }
      inputFile=new BufferedReader(new InputStreamReader(inputFileURL.openStream()));
    }
  }
  return inputFile;
}
Program: 72589
Project: 72589
Buggy source:
/** 
 * Reads mapping constraints from a file. MappingConstraintSolver
 * @param filename Filename of the mapping constraint file.
 * @return the constraint file in a string.
 * @exception IOException a failed or interrupted I/O operations has occurred.
 */
public static String readMappingFile(String filename) throws IOException {
  FileInputStream stream=new FileInputStream(filename);
  DataInputStream in=new DataInputStream(stream);
  BufferedReader reader=new BufferedReader(new InputStreamReader(in));
  String line;
  StringBuilder stringBuilder=new StringBuilder();
  try {
    while ((line=reader.readLine()) != null) {
      stringBuilder.append(line);
      stringBuilder.append('\n');
    }
    return stringBuilder.toString();
  }
  finally {
    reader.close();
  }
}

Fixed version (ground truth):
/** 
 * Reads mapping constraints from a file. MappingConstraintSolver
 * @param filename Filename of the mapping constraint file.
 * @return the constraint file in a string.
 * @exception IOException a failed or interrupted I/O operations has occurred.
 */
public static String readMappingFile(String filename) throws IOException {
  FileInputStream stream=new FileInputStream(filename);
  DataInputStream in=new DataInputStream(stream);
  BufferedReader reader=new BufferedReader(new InputStreamReader(in,java.nio.charset.Charset.defaultCharset()));
  String line;
  StringBuilder stringBuilder=new StringBuilder();
  try {
    while ((line=reader.readLine()) != null) {
      stringBuilder.append(line);
      stringBuilder.append('\n');
    }
    return stringBuilder.toString();
  }
  finally {
    reader.close();
  }
}
Program: 72592
Project: 72592
Buggy source:
/** 
 * Return the value given by the configure tag.  This is the text read from the specified URL (if any), followed by the text specified in the body of the configure element.  Note that the URL given in the configure() method, if any, is read each time this method is called.
 * @return The value set in the configure tag.
 * @exception IOException If the URL given in the configure method(if any) cannot be read.
 */
public String value() throws IOException {
  StringBuffer value=new StringBuffer();
  if (_configureSource != null && !_configureSource.trim().equals("String_Node_Str")) {
    URL textFile=new URL(_configureSource);
    InputStream stream=textFile.openStream();
    BufferedReader reader=null;
    try {
      reader=new BufferedReader(new InputStreamReader(stream));
      String line=reader.readLine();
      while (line != null) {
        value.append(line);
        value.append("String_Node_Str");
        line=reader.readLine();
      }
    }
  finally {
      if (reader != null) {
        reader.close();
      }
    }
    stream.close();
  }
  if (_configureText != null) {
    value.append(_configureText);
  }
  return value.toString();
}

Fixed version (ground truth):
/** 
 * Return the value given by the configure tag.  This is the text read from the specified URL (if any), followed by the text specified in the body of the configure element.  Note that the URL given in the configure() method, if any, is read each time this method is called.
 * @return The value set in the configure tag.
 * @exception IOException If the URL given in the configure method(if any) cannot be read.
 */
public String value() throws IOException {
  StringBuffer value=new StringBuffer();
  if (_configureSource != null && !_configureSource.trim().equals("String_Node_Str")) {
    URL textFile=new URL(_configureSource);
    InputStream stream=textFile.openStream();
    BufferedReader reader=null;
    try {
      reader=new BufferedReader(new InputStreamReader(stream,java.nio.charset.Charset.defaultCharset()));
      String line=reader.readLine();
      while (line != null) {
        value.append(line);
        value.append("String_Node_Str");
        line=reader.readLine();
      }
    }
  finally {
      if (reader != null) {
        reader.close();
      }
    }
    stream.close();
  }
  if (_configureText != null) {
    value.append(_configureText);
  }
  return value.toString();
}
Program: 72598
Project: 72598
Buggy source:
/** 
 * Instantiate a Java representation of the C structure that contains the FMI call backs.
 * @param logger The method called to log a status message(C type: fmiCallbackLogger).
 * @param allocateMemory The method called to allocate cleared memory(C type: fmiCallbackAllocateMemory
 * @param freeMemory The method called to free allocated memory(C type: fmiCallbackFreeMemory)
 * @param stepFinished The method called when the step is finished.(C type: FmiStepFinished)
 */
public FMICallbackFunctions(FMICallbackLogger logger,FMICallbackAllocateMemory allocateMemory,FMICallbackFreeMemory freeMemory,FMIStepFinished stepFinished){
  super();
  this.logger=logger;
  this.allocateMemory=allocateMemory;
  this.freeMemory=freeMemory;
  this.stepFinished=stepFinished;
  setAlignType(Structure.ALIGN_GNUC);
}

Fixed version (ground truth):
/** 
 * Instantiate a Java representation of the C structure that contains the FMI call backs.
 * @param logger The method called to log a status message(C type: fmiCallbackLogger).
 * @param allocateMemory The method called to allocate cleared memory(C type: fmiCallbackAllocateMemory
 * @param freeMemory The method called to free allocated memory(C type: fmiCallbackFreeMemory)
 * @param stepFinished The method called when the step is finished.(C type: FmiStepFinished)
 */
public FMICallbackFunctions(FMICallbackLogger logger,FMICallbackAllocateMemory allocateMemory,FMICallbackFreeMemory freeMemory,FMIStepFinished stepFinished){
  super();
  this.logger=logger;
  this.allocateMemory=allocateMemory;
  this.freeMemory=freeMemory;
  this.stepFinished=stepFinished;
}
Program: 72599
Project: 72599
Buggy source:
/** 
 * Get the native library of C functions for the current platform. A side effect is that if the native library does not exist, then  {@link org.ptolemy.fmi.FMUBuilder#build(File)} is invoked, which maybuild the shared library.
 * @return The library of functions for the current platform.
 * @exception IOException If the FMU file does not contain binaries for the current platform.
 */
public NativeLibrary getNativeLibrary() throws IOException {
  if (_nativeLibrary != null) {
    return _nativeLibrary;
  }
  String sharedLibrary=getNativeLibraryPath();
  try {
    Map options=new HashMap();
    options.put(Library.OPTION_OPEN_FLAGS,new Integer(1));
    _nativeLibrary=NativeLibrary.getInstance(sharedLibrary,options);
  }
 catch (  Throwable throwable3) {
    IOException exception=new IOException("String_Node_Str" + sharedLibrary + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    exception.initCause(throwable3);
    throw exception;
  }
  return _nativeLibrary;
}

Fixed version (ground truth):
/** 
 * Get the native library of C functions for the current platform. A side effect is that if the native library does not exist, then  {@link org.ptolemy.fmi.FMUBuilder#build(File)} is invoked, which maybuild the shared library.
 * @return The library of functions for the current platform.
 * @exception IOException If the FMU file does not contain binaries for the current platform.
 */
public NativeLibrary getNativeLibrary() throws IOException {
  if (_nativeLibrary != null) {
    return _nativeLibrary;
  }
  String sharedLibrary=getNativeLibraryPath();
  try {
    String osName=System.getProperty("String_Node_Str").toLowerCase(Locale.getDefault());
    if (osName.startsWith("String_Node_Str")) {
      Map options=new HashMap();
      Integer RTLD_LAZY=new Integer(1);
      options.put(Library.OPTION_OPEN_FLAGS,RTLD_LAZY);
      _nativeLibrary=NativeLibrary.getInstance(sharedLibrary,options);
    }
 else {
      _nativeLibrary=NativeLibrary.getInstance(sharedLibrary);
    }
  }
 catch (  Throwable throwable3) {
    IOException exception=new IOException("String_Node_Str" + sharedLibrary + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    exception.initCause(throwable3);
    throw exception;
  }
  return _nativeLibrary;
}
Program: 72603
Project: 72603
Buggy source:
private void _init() throws IllegalActionException, NameDuplicationException {
  particles=new TypedIOPort(this,"String_Node_Str",true,false);
  ArrayToken names=new ArrayToken("String_Node_Str");
  String stateName;
  _labels=new String[names.length() + 1];
  _types=new Type[names.length() + 1];
  for (int i=0; i < names.length(); i++) {
    stateName=((StringToken)names.getElement(i)).stringValue();
    _labels[i]=stateName;
    _types[i]=BaseType.DOUBLE;
  }
  _labels[names.length()]="String_Node_Str";
  _types[names.length()]=BaseType.DOUBLE;
  particles.setTypeEquals(new ArrayType(new RecordType(_labels,_types)));
  _px=new double[0];
  _py=new double[0];
  _weights=new double[0];
  locations=new TypedIOPort(this,"String_Node_Str",true,false);
  _robotLocations=new LinkedList<RecordToken>();
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeEquals(BaseType.DOUBLE);
  _covariance=2.0;
}

Fixed version (ground truth):
private void _init() throws IllegalActionException, NameDuplicationException {
  particles=new TypedIOPort(this,"String_Node_Str",true,false);
  ArrayToken names=new ArrayToken("String_Node_Str");
  String stateName;
  _labels=new String[names.length() + 1];
  _types=new Type[names.length() + 1];
  for (int i=0; i < names.length(); i++) {
    stateName=((StringToken)names.getElement(i)).stringValue();
    _labels[i]=stateName;
    _types[i]=BaseType.DOUBLE;
  }
  _labels[names.length()]="String_Node_Str";
  _types[names.length()]=BaseType.DOUBLE;
  particles.setTypeEquals(new ArrayType(new RecordType(_labels,_types)));
  _px=new double[0];
  _py=new double[0];
  _weights=new double[0];
  locations=new TypedIOPort(this,"String_Node_Str",true,false);
  _robotLocations=new LinkedList<RecordToken>();
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeEquals(BaseType.DOUBLE);
  _firstStep=true;
  _covariance=2.0;
}
Program: 72604
Project: 72604
Buggy source:
@Override public void fire() throws IllegalActionException {
  super.fire();
  if (particles.hasToken(0)) {
    ArrayToken incoming=(ArrayToken)particles.get(0);
    N=incoming.length();
    _weights=new double[N];
    if (_px.length == 0) {
      _px=new double[N];
      _py=new double[N];
      _weights=new double[N];
    }
    for (int i=0; i < N; i++) {
      RecordToken token=(RecordToken)incoming.getElement(i);
      for (int k=0; k < _labels.length; k++) {
        if (_labels[k].equals("String_Node_Str")) {
          _weights[i]=((DoubleToken)token.get(_labels[k])).doubleValue();
        }
 else         if (_labels[k].equals("String_Node_Str")) {
          _px[i]=((DoubleToken)token.get(_labels[k])).doubleValue();
        }
 else         if (_labels[k].equals("String_Node_Str")) {
          _py[i]=((DoubleToken)token.get(_labels[k])).doubleValue();
        }
      }
    }
    double wsum=0;
    for (int i=0; i < N; i++) {
      wsum+=_weights[i];
    }
    for (int i=0; i < N; i++) {
      _weights[i]/=wsum;
    }
  }
  if (locations.hasToken(0)) {
    ArrayToken robotLocations=(ArrayToken)locations.get(0);
    _nRobots=robotLocations.length();
    _robotLocations.clear();
    for (int i=0; i < _nRobots; i++) {
      RecordToken robotLocation=(RecordToken)robotLocations.getElement(i);
      _robotLocations.add(robotLocation);
    }
  }
  output.send(0,new DoubleToken(Hz(_xValue)));
}

Fixed version (ground truth):
@Override public void fire() throws IllegalActionException {
  super.fire();
  if (particles.hasToken(0)) {
    ArrayToken incoming=(ArrayToken)particles.get(0);
    N=incoming.length();
    if (_firstStep) {
      _px=new double[N];
      _py=new double[N];
      _weights=new double[N];
      _firstStep=false;
    }
    for (int i=0; i < N; i++) {
      RecordToken token=(RecordToken)incoming.getElement(i);
      for (int k=0; k < _labels.length; k++) {
        if (_labels[k].equals("String_Node_Str")) {
          _weights[i]=((DoubleToken)token.get(_labels[k])).doubleValue();
        }
 else         if (_labels[k].equals("String_Node_Str")) {
          _px[i]=((DoubleToken)token.get(_labels[k])).doubleValue();
        }
 else         if (_labels[k].equals("String_Node_Str")) {
          _py[i]=((DoubleToken)token.get(_labels[k])).doubleValue();
        }
      }
    }
    double wsum=0;
    for (int i=0; i < N; i++) {
      wsum+=_weights[i];
    }
    for (int i=0; i < N; i++) {
      _weights[i]/=wsum;
    }
  }
  if (locations.hasToken(0)) {
    ArrayToken robotLocations=(ArrayToken)locations.get(0);
    _nRobots=robotLocations.length();
    _robotLocations.clear();
    for (int i=0; i < _nRobots; i++) {
      RecordToken robotLocation=(RecordToken)robotLocations.getElement(i);
      _robotLocations.add(robotLocation);
    }
  }
  output.send(0,new DoubleToken(Hz(_xValue)));
}
Program: 72605
Project: 72605
Buggy source:
/** 
 * Remove all decorated ports from the container
 * @throws NameDuplicationException 
 * @throws IllegalActionException 
 */
public void removeDecorationsFromContainer(){
  super.removeDecorationsFromContainer();
  removeStateSpaceVariablesFromContainer();
}

Fixed version (ground truth):
/** 
 * Remove all decorated ports from the container
 * @throws NameDuplicationException 
 * @throws IllegalActionException 
 */
public void removeDecorationsFromContainer() throws IllegalActionException, NameDuplicationException {
  super.removeDecorationsFromContainer();
  removeStateSpaceVariablesFromContainer();
}
Program: 72606
Project: 72606
Buggy source:
/** 
 * Create the parameters. Including any parameter the decorator already includes.
 */
private void _init(){
  try {
    enable=new Parameter(this,"String_Node_Str");
    enable.setExpression("String_Node_Str");
    enable.setTypeEquals(BaseType.BOOLEAN);
    enable.setPersistent(true);
    _addAllParameters();
  }
 catch (  KernelException ex) {
    throw new InternalErrorException(ex);
  }
}

Fixed version (ground truth):
/** 
 * Create the parameters. Including any parameter the decorator already includes.
 */
private void _init(){
  _cachedDecoratorPorts=new HashMap<>();
  _cachedDecoratorPortParameters=new HashMap<>();
  try {
    enable=new Parameter(this,"String_Node_Str");
    enable.setExpression("String_Node_Str");
    enable.setTypeEquals(BaseType.BOOLEAN);
    enable.setPersistent(true);
    _addAllParameters();
  }
 catch (  KernelException ex) {
    throw new InternalErrorException(ex);
  }
}
Program: 72607
Project: 72607
Buggy source:
/** 
 * React to a change in an attribute.  If the attribute is <i>enable</i>, remember the value.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container (not thrown in this base class).
 */
@Override public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == enable) {
    _enabled=((BooleanToken)enable.getToken()).booleanValue();
    if (enabled()) {
      decorateContainer();
    }
 else {
      removeDecorationsFromContainer();
    }
  }
  super.attributeChanged(attribute);
}

Fixed version (ground truth):
/** 
 * React to a change in an attribute.  If the attribute is <i>enable</i>, remember the value.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container (not thrown in this base class).
 */
@Override public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == enable) {
    _enabled=((BooleanToken)enable.getToken()).booleanValue();
    if (enabled()) {
      decorateContainer();
    }
 else {
      try {
        removeDecorationsFromContainer();
      }
 catch (      NameDuplicationException e) {
        throw new InternalErrorException(e);
      }
    }
  }
  super.attributeChanged(attribute);
}
Program: 72608
Project: 72608
Buggy source:
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  MirrorDecoratorAttributes result=(MirrorDecoratorAttributes)super.clone(workspace);
  result._enabled=false;
  return result;
}

Fixed version (ground truth):
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  MirrorDecoratorAttributes result=(MirrorDecoratorAttributes)super.clone(workspace);
  result._enabled=false;
  result._cachedDecoratorPortParameters=null;
  result._cachedDecoratorPorts=null;
  return result;
}
Program: 72609
Project: 72609
Buggy source:
/** 
 * Remove all decorated ports from the container
 * @throws NameDuplicationException 
 * @throws IllegalActionException 
 */
public void removeDecorationsFromContainer(){
  if (this._decorator != null) {
    List<String> addedPortNames=((MirrorDecorator)this._decorator).getAddedPortNames();
    if (addedPortNames != null) {
      for (      String port : addedPortNames) {
        event((MirrorDecorator)this._decorator,DecoratorEvent.REMOVED_PORT,port);
      }
    }
    List<String> addedPortParNames=((MirrorDecorator)this._decorator).getAddedPortParameterNames();
    if (addedPortNames != null) {
      for (      String decoratorPort : addedPortParNames) {
        event((MirrorDecorator)this._decorator,DecoratorEvent.REMOVED_PORT,(Parameter)((MirrorDecorator)this._decorator).getAttribute(decoratorPort));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove all decorated ports from the container
 * @throws NameDuplicationException 
 * @throws IllegalActionException 
 */
public void removeDecorationsFromContainer() throws IllegalActionException, NameDuplicationException {
  if (this._decorator != null) {
    for (    Port p : _cachedDecoratorPorts.values()) {
      p.setContainer(null);
    }
    for (    Parameter p : _cachedDecoratorPortParameters.values()) {
      ParameterPort expectedPort=(ParameterPort)((ComponentEntity)this.getContainer()).getPort(p.getName());
      if (expectedPort != null) {
        expectedPort.setContainer(null);
      }
      p.setContainer(null);
    }
    _cachedDecoratorPorts.clear();
    _cachedDecoratorPortParameters.clear();
  }
}
Program: 72611
Project: 72611
Buggy source:
/** 
 * Initialize ports and parameters.
 * @exception IllegalActionException
 * @exception NameDuplicationException
 */
private void _init() throws IllegalActionException, NameDuplicationException {
  publish=new TypedIOPort(this,"String_Node_Str",true,false);
  subscribe=new TypedIOPort(this,"String_Node_Str",false,true);
  subscribe.setTypeEquals(BaseType.STRING);
  address=new Parameter(this,"String_Node_Str");
  host=new Parameter(this,"String_Node_Str");
  port=new Parameter(this,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Initialize ports and parameters.
 * @exception IllegalActionException
 * @exception NameDuplicationException
 */
private void _init() throws IllegalActionException, NameDuplicationException {
  publish=new TypedIOPort(this,"String_Node_Str",true,false);
  subscribe=new TypedIOPort(this,"String_Node_Str",false,true);
  address=new Parameter(this,"String_Node_Str");
  host=new Parameter(this,"String_Node_Str");
  port=new Parameter(this,"String_Node_Str");
}
Program: 72612
Project: 72612
Buggy source:
/** 
 * If there is a token on the input, convert the token to a json object and publish that to the event bus.
 */
@Override public void fire() throws IllegalActionException {
  if (_exception != null) {
    throw new IllegalActionException(this,_exception,_exception.getMessage());
  }
  for (int i=0; i < publish.getWidth(); i++) {
    if (publish.hasToken(i)) {
      String tokenString=publish.get(0).toString();
      JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address).putString("String_Node_Str",tokenString);
      _sendTextFrame(msg);
    }
  }
  if (_buffer != null) {
    List<StringToken> _bufferCopy=new ArrayList<StringToken>();
synchronized (_buffer) {
      if (_buffer.size() > 0) {
        _bufferCopy.addAll(_buffer);
        _buffer.clear();
      }
    }
    for (int i=0; i < _bufferCopy.size(); i++) {
      subscribe.send(0,_bufferCopy.get(i));
    }
  }
}

Fixed version (ground truth):
/** 
 * If there is a token on the input, convert the token to a json object and publish that to the event bus.
 */
@Override public void fire() throws IllegalActionException {
  if (_exception != null) {
    throw new IllegalActionException(this,_exception,_exception.getMessage());
  }
  for (int i=0; i < publish.getWidth(); i++) {
    if (publish.hasToken(i)) {
      String tokenString=publish.get(0).toString();
      JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address).putString("String_Node_Str",tokenString);
      _sendTextFrame(msg);
    }
  }
  if (_buffer != null) {
    List<Token> bufferCopy=new ArrayList<Token>();
synchronized (_buffer) {
      if (_buffer.size() > 0) {
        bufferCopy.addAll(_buffer);
        _buffer.clear();
      }
    }
    for (int i=0; i < bufferCopy.size(); i++) {
      subscribe.send(0,bufferCopy.get(i));
    }
  }
}
Program: 72614
Project: 72614
Buggy source:
/** 
 * Initialize verticle, create http client and open web socket to connect to event bus.
 * @throws IllegalActionException 
 */
@Override public void initialize() throws IllegalActionException {
  _exception=null;
  _vertx=VertxFactory.newVertx();
  _client=_vertx.createHttpClient().setHost(_host).setPort(_port);
  _openWebSocket();
  _periodicPing=_vertx.setPeriodic(1000,new Handler<Long>(){
    @Override public void handle(    Long timerID){
      JsonObject json=new JsonObject().putString("String_Node_Str","String_Node_Str");
      try {
        _sendTextFrame(json);
      }
 catch (      IllegalActionException e) {
        _exception=e;
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Initialize verticle, create http client and open web socket to connect to event bus.
 * @throws IllegalActionException 
 */
@Override public void initialize() throws IllegalActionException {
  _exception=null;
  _vertx=VertxFactory.newVertx();
  _client=_vertx.createHttpClient().setHost(_host).setPort(_port);
  _openWebSocket();
  _periodicPing=_vertx.setPeriodic(5000,new Handler<Long>(){
    @Override public void handle(    Long timerID){
      JsonObject json=new JsonObject().putString("String_Node_Str","String_Node_Str");
      try {
        _sendTextFrame(json);
      }
 catch (      IllegalActionException e) {
        _exception=e;
      }
    }
  }
);
}
Program: 72615
Project: 72615
Buggy source:
/** 
 * Wrap up, close web socket if open, stop vertx.
 */
@Override public synchronized void wrapup() throws IllegalActionException {
  super.wrapup();
  _vertx.cancelTimer(_periodicPing);
  _vertx.stop();
}

Fixed version (ground truth):
/** 
 * Wrap up, close web socket if open, stop vertx.
 */
@Override public synchronized void wrapup() throws IllegalActionException {
  super.wrapup();
  _vertx.cancelTimer(_periodicPing);
  _vertx.stop();
  _websocket=null;
}
Program: 72616
Project: 72616
Buggy source:
/** 
 * Open a web socket that serves as a connection to the event bus.
 */
private synchronized void _openWebSocket(){
  if (!_stopRequested) {
    _client.connectWebsocket("String_Node_Str",new Handler<WebSocket>(){
      @Override public void handle(      WebSocket websocket){
        JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address);
        websocket.writeTextFrame(msg.encode());
        _websocket=websocket;
        websocket.dataHandler(new Handler<Buffer>(){
          @Override public void handle(          Buffer buff){
            String msg=buff.toString();
            JsonObject received=new JsonObject(msg);
            if (_buffer == null) {
              _buffer=new ArrayList<StringToken>();
            }
synchronized (_buffer) {
              _buffer.add(new StringToken(received.getField("String_Node_Str").toString()));
            }
            try {
              getDirector().fireAtCurrentRealTime((Actor)subscribe.getContainer());
            }
 catch (            IllegalActionException e) {
              e.printStackTrace();
            }
          }
        }
);
      }
    }
);
    _client.exceptionHandler(new Handler<Throwable>(){
      @Override public void handle(      Throwable event){
        _exception=event;
        _vertx.cancelTimer(_periodicPing);
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * Open a web socket that serves as a connection to the event bus.
 */
private void _openWebSocket(){
  if (!_stopRequested) {
    _client.connectWebsocket("String_Node_Str",new Handler<WebSocket>(){
      @Override public void handle(      WebSocket websocket){
        JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address);
        websocket.writeTextFrame(msg.encode());
        _websocket=websocket;
        websocket.dataHandler(new Handler<Buffer>(){
          @Override public void handle(          Buffer buff){
            String msg=buff.toString();
            JsonObject received=new JsonObject(msg);
            if (_buffer == null) {
              _buffer=new ArrayList<StringToken>();
            }
synchronized (_buffer) {
              if (received.getField("String_Node_Str") != null) {
                _buffer.add(new StringToken(received.getField("String_Node_Str").toString()));
              }
            }
            try {
              getDirector().fireAtCurrentRealTime((Actor)subscribe.getContainer());
            }
 catch (            IllegalActionException e) {
              e.printStackTrace();
            }
          }
        }
);
      }
    }
);
    _client.exceptionHandler(new Handler<Throwable>(){
      @Override public void handle(      Throwable event){
        _exception=event;
        _vertx.cancelTimer(_periodicPing);
      }
    }
);
  }
}