nus-yam/ex-repair huggingface dataset:
Program: 38877
Project: 38877
Buggy source:
public static ComputationManager createMpiComputationManager(CommandLine line,FileSystem fileSystem){
  Path tmpDir=fileSystem.getPath(line.hasOption("String_Node_Str") ? line.getOptionValue("String_Node_Str") : System.getProperty("String_Node_Str"));
  Path statisticsDbDir=line.hasOption("String_Node_Str") ? fileSystem.getPath(line.getOptionValue("String_Node_Str")) : null;
  String statisticsDbName=line.hasOption("String_Node_Str") ? line.getOptionValue("String_Node_Str") : null;
  int coresPerRank=Integer.parseInt(line.getOptionValue("String_Node_Str"));
  boolean verbose=line.hasOption("String_Node_Str");
  Path stdOutArchive=line.hasOption("String_Node_Str") ? fileSystem.getPath(line.getOptionValue("String_Node_Str")) : null;
  ComponentDefaultConfig config=ComponentDefaultConfig.load();
  MpiStatisticsFactory statisticsFactory=createMpiStatisticsFactory(config,statisticsDbDir,statisticsDbName);
  try {
    return new MpiComputationManager(tmpDir,statisticsFactory.create(statisticsDbDir,statisticsDbName),new MpiExecutorContext(),coresPerRank,verbose,stdOutArchive);
  }
 catch (  IOException e) {
    throw new UncheckedIOException(e);
  }
catch (  InterruptedException e) {
    throw new UncheckedInterruptedException(e);
  }
}

Fixed version (ground truth):
public static ComputationManager createMpiComputationManager(CommandLine line,FileSystem fileSystem){
  Path tmpDir=fileSystem.getPath(line.hasOption("String_Node_Str") ? line.getOptionValue("String_Node_Str") : System.getProperty("String_Node_Str"));
  Path statisticsDbDir=line.hasOption("String_Node_Str") ? fileSystem.getPath(line.getOptionValue("String_Node_Str")) : null;
  String statisticsDbName=line.hasOption("String_Node_Str") ? line.getOptionValue("String_Node_Str") : null;
  int coresPerRank=Integer.parseInt(line.getOptionValue("String_Node_Str"));
  boolean verbose=line.hasOption("String_Node_Str");
  Path stdOutArchive=line.hasOption("String_Node_Str") ? fileSystem.getPath(line.getOptionValue("String_Node_Str")) : null;
  ComponentDefaultConfig config=ComponentDefaultConfig.load();
  MpiStatisticsFactory statisticsFactory=createMpiStatisticsFactory(config,statisticsDbDir,statisticsDbName);
  try {
    return new MpiComputationManager(tmpDir,statisticsFactory.create(statisticsDbDir,statisticsDbName),new MpiExecutorContext(),coresPerRank,verbose,stdOutArchive);
  }
 catch (  IOException e) {
    throw new UncheckedIOException(e);
  }
catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new UncheckedInterruptedException(e);
  }
}
Program: 38878
Project: 38878
Buggy source:
@Override public Expression transform(Expression exp){
  if (exp instanceof BinaryExpression) {
    BinaryExpression binExpr=(BinaryExpression)exp;
    String op=binExpr.getOperation().getText();
switch (op) {
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
      return new MethodCallExpression(transform(binExpr.getLeftExpression()),"String_Node_Str",new ArgumentListExpression(transform(binExpr.getRightExpression()),new ConstantExpression(op)));
case "String_Node_Str":
    return new MethodCallExpression(transform(binExpr.getLeftExpression()),"String_Node_Str",new ArgumentListExpression(transform(binExpr.getRightExpression())));
case "String_Node_Str":
  return new MethodCallExpression(transform(binExpr.getLeftExpression()),"String_Node_Str",new ArgumentListExpression(transform(binExpr.getRightExpression())));
}
}
 else if (exp instanceof NotExpression) {
return new MethodCallExpression(transform(((NotExpression)exp).getExpression()),"String_Node_Str",new ArgumentListExpression());
}
Expression newExpr=super.transform(exp);
if (newExpr != null) {
newExpr.visit(this);
}
return newExpr;
}

Fixed version (ground truth):
@Override public Expression transform(Expression exp){
  if (exp instanceof BinaryExpression) {
    BinaryExpression binExpr=(BinaryExpression)exp;
    String op=binExpr.getOperation().getText();
switch (op) {
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
      return new MethodCallExpression(transform(binExpr.getLeftExpression()),"String_Node_Str",new ArgumentListExpression(transform(binExpr.getRightExpression()),new ConstantExpression(op)));
case "String_Node_Str":
    return new MethodCallExpression(transform(binExpr.getLeftExpression()),"String_Node_Str",new ArgumentListExpression(transform(binExpr.getRightExpression())));
case "String_Node_Str":
  return new MethodCallExpression(transform(binExpr.getLeftExpression()),"String_Node_Str",new ArgumentListExpression(transform(binExpr.getRightExpression())));
default :
break;
}
}
 else if (exp instanceof NotExpression) {
return new MethodCallExpression(transform(((NotExpression)exp).getExpression()),"String_Node_Str",new ArgumentListExpression());
}
Expression newExpr=super.transform(exp);
if (newExpr != null) {
newExpr.visit(this);
}
return newExpr;
}
Program: 38879
Project: 38879
Buggy source:
private static int compare(BranchAndSide branchAndSide1,BranchAndSide branchAndSide2){
  Branch.Overload overload1=branchAndSide1.getBranch().checkTemporaryLimits(branchAndSide1.getSide());
  Branch.Overload overload2=branchAndSide2.getBranch().checkTemporaryLimits(branchAndSide2.getSide());
  float i1=branchAndSide1.getBranch().getTerminal(branchAndSide1.getSide()).getI();
  float i2=branchAndSide2.getBranch().getTerminal(branchAndSide2.getSide()).getI();
  float permanentLimit1=getPermanentLimit(branchAndSide1.getBranch(),branchAndSide1.getSide());
  float permanentLimit2=getPermanentLimit(branchAndSide2.getBranch(),branchAndSide2.getSide());
  int c;
  if (overload1 == null && overload2 == null) {
    c=compare(i1 / permanentLimit1,i2 / permanentLimit2);
  }
 else   if (overload1 == null && overload2 != null) {
    c=-1;
  }
 else   if (overload1 != null && overload2 == null) {
    c=1;
  }
 else {
    c=-Integer.compare(overload1.getTemporaryLimit().getAcceptableDuration(),overload2.getTemporaryLimit().getAcceptableDuration());
    if (c == 0) {
      c=compare(i1 / overload1.getTemporaryLimit().getValue(),i2 / overload2.getTemporaryLimit().getValue());
    }
  }
  return c;
}

Fixed version (ground truth):
private static int compare(BranchAndSide branchAndSide1,BranchAndSide branchAndSide2){
  Branch.Overload overload1=branchAndSide1.getBranch().checkTemporaryLimits(branchAndSide1.getSide());
  Branch.Overload overload2=branchAndSide2.getBranch().checkTemporaryLimits(branchAndSide2.getSide());
  float i1=branchAndSide1.getBranch().getTerminal(branchAndSide1.getSide()).getI();
  float i2=branchAndSide2.getBranch().getTerminal(branchAndSide2.getSide()).getI();
  float permanentLimit1=getPermanentLimit(branchAndSide1.getBranch(),branchAndSide1.getSide());
  float permanentLimit2=getPermanentLimit(branchAndSide2.getBranch(),branchAndSide2.getSide());
  int c;
  if (overload1 == null) {
    if (overload2 == null) {
      c=compare(i1 / permanentLimit1,i2 / permanentLimit2);
    }
 else {
      c=-1;
    }
  }
 else {
    if (overload2 == null) {
      c=1;
    }
 else {
      c=-Integer.compare(overload1.getTemporaryLimit().getAcceptableDuration(),overload2.getTemporaryLimit().getAcceptableDuration());
      if (c == 0) {
        c=compare(i1 / overload1.getTemporaryLimit().getValue(),i2 / overload2.getTemporaryLimit().getValue());
      }
    }
  }
  return c;
}
Program: 38880
Project: 38880
Buggy source:
private List<String> sortBranches(List<String> branchIds){
  List<String> sortedBranchIds=branchIds.stream().map(id -> context.getNetwork().getBranch(id)).map(branch -> {
    BranchAndSide branchAndSide1=new BranchAndSide(branch,Branch.Side.ONE);
    BranchAndSide branchAndSide2=new BranchAndSide(branch,Branch.Side.TWO);
    int c=branchAndSide1.compareTo(branchAndSide2);
    return c >= 0 ? branchAndSide1 : branchAndSide2;
  }
).sorted().map(branchAndSide -> branchAndSide.getBranch().getId()).collect(Collectors.toList());
  return sortedBranchIds;
}

Fixed version (ground truth):
private List<String> sortBranches(List<String> branchIds){
  return branchIds.stream().map(id -> context.getNetwork().getBranch(id)).map(branch -> {
    BranchAndSide branchAndSide1=new BranchAndSide(branch,Branch.Side.ONE);
    BranchAndSide branchAndSide2=new BranchAndSide(branch,Branch.Side.TWO);
    int c=branchAndSide1.compareTo(branchAndSide2);
    return c >= 0 ? branchAndSide1 : branchAndSide2;
  }
).sorted().map(branchAndSide -> branchAndSide.getBranch().getId()).collect(Collectors.toList());
}
Program: 38881
Project: 38881
Buggy source:
@Override public Object visitLoadingRank(LoadingRankNode node,Void arg){
  List<String> branchIds=new ArrayList<>();
  node.getBranchIds().forEach(e -> branchIds.add((String)e.accept(this,arg)));
  String branchIdToRank=(String)node.getBranchIdToRankNode().accept(this,arg);
  if (!branchIds.contains(branchIdToRank)) {
    throw new PowsyblException("String_Node_Str");
  }
  List<String> sortedBranchIds=sortBranches(branchIds);
  int i=sortedBranchIds.indexOf(branchIdToRank);
  if (i == -1) {
    throw new AssertionError();
  }
  int rank=sortedBranchIds.size() - i;
  return rank;
}

Fixed version (ground truth):
@Override public Object visitLoadingRank(LoadingRankNode node,Void arg){
  List<String> branchIds=new ArrayList<>();
  node.getBranchIds().forEach(e -> branchIds.add((String)e.accept(this,arg)));
  String branchIdToRank=(String)node.getBranchIdToRankNode().accept(this,arg);
  if (!branchIds.contains(branchIdToRank)) {
    throw new PowsyblException("String_Node_Str");
  }
  List<String> sortedBranchIds=sortBranches(branchIds);
  int i=sortedBranchIds.indexOf(branchIdToRank);
  if (i == -1) {
    throw new AssertionError();
  }
  return sortedBranchIds.size() - i;
}
Program: 38882
Project: 38882
Buggy source:
public abstract FOLDER getParent();

Fixed version (ground truth):
public abstract F getParent();
Program: 38883
Project: 38883
Buggy source:
FOLDER getFolder(String name,String... more);

Fixed version (ground truth):
F getFolder(String name,String... more);
Program: 38884
Project: 38884
Buggy source:
List<NODE> getChildren();

Fixed version (ground truth):
List<N> getChildren();
Program: 38885
Project: 38885
Buggy source:
<T extends NODE>T getChild(Class<T> clazz,String name,String... more);

Fixed version (ground truth):
<T extends N>T getChild(Class<T> clazz,String name,String... more);
Program: 38886
Project: 38886
Buggy source:
FOLDER createFolder(String name);

Fixed version (ground truth):
F createFolder(String name);
Program: 38887
Project: 38887
Buggy source:
public static <FOLDER extends NODE,NODE extends AbstractNodeBase<FOLDER>>NodePath find(NODE node,Function<List<String>,String> toStringFct){
  Objects.requireNonNull(node);
  List<String> path=new ArrayList<>(1);
  addPath(node,path);
  return new NodePath(path,toStringFct);
}

Fixed version (ground truth):
public static <F extends N,N extends AbstractNodeBase<F>>NodePath find(N node,Function<List<String>,String> toStringFct){
  Objects.requireNonNull(node);
  List<String> path=new ArrayList<>(1);
  addPath(node,path);
  return new NodePath(path,toStringFct);
}
Program: 38888
Project: 38888
Buggy source:
private static <FOLDER extends NODE,NODE extends AbstractNodeBase<FOLDER>>void addPath(NODE node,List<String> path){
  if (node.getParent() != null) {
    addPath(node.getParent(),path);
  }
  path.add(node.getName());
}

Fixed version (ground truth):
private static <F extends N,N extends AbstractNodeBase<F>>void addPath(N node,List<String> path){
  if (node.getParent() != null) {
    addPath(node.getParent(),path);
  }
  path.add(node.getName());
}
Program: 38889
Project: 38889
Buggy source:
@Override public List<NodeId> getChildNodes(NodeId nodeId){
  Objects.requireNonNull(nodeId);
  Path path=((PathNodeId)nodeId).getPath();
  List<NodeId> childNodesIds=new ArrayList<>();
  LocalFolder folder=scanFolder(path,false);
  if (folder != null) {
    childNodesIds.addAll(folder.getChildPaths().stream().filter(childPath -> isLocalNode(childPath)).map(childPath -> new PathNodeId(childPath)).collect(Collectors.toList()));
  }
 else {
    throw new AssertionError();
  }
  return childNodesIds;
}

Fixed version (ground truth):
@Override public List<NodeId> getChildNodes(NodeId nodeId){
  Objects.requireNonNull(nodeId);
  Path path=((PathNodeId)nodeId).getPath();
  List<NodeId> childNodesIds=new ArrayList<>();
  LocalFolder folder=scanFolder(path,false);
  if (folder != null) {
    childNodesIds.addAll(folder.getChildPaths().stream().filter(this::isLocalNode).map(PathNodeId::new).collect(Collectors.toList()));
  }
 else {
    throw new AssertionError();
  }
  return childNodesIds;
}
Program: 38890
Project: 38890
Buggy source:
@Override public void close() throws IOException {
  os.closeEntry();
  if (Files.exists(zipFilePath)) {
    try (ZipFile zipFile=new ZipFile(zipFilePath)){
      Enumeration<? extends ZipEntry> e=zipFile.entries();
      while (e.hasMoreElements()) {
        ZipEntry zipEntry=e.nextElement();
        if (!zipEntry.getName().equals(fileName)) {
          zos.putNextEntry(zipEntry);
          try (InputStream zis=zipFile.getInputStream(zipEntry.getName())){
            ByteStreams.copy(zis,zos);
          }
           zos.closeEntry();
        }
      }
    }
   }
  zos.close();
  Files.copy(tmpZipFilePath,zipFilePath,StandardCopyOption.REPLACE_EXISTING);
  Files.delete(tmpZipFilePath);
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  os.closeEntry();
  if (Files.exists(zipFilePath)) {
    try (ZipFile zipFile=new ZipFile(zipFilePath)){
      Enumeration<? extends ZipEntry> e=zipFile.entries();
      while (e.hasMoreElements()) {
        ZipEntry zipEntry=e.nextElement();
        if (!zipEntry.getName().equals(fileName)) {
          os.putNextEntry(zipEntry);
          try (InputStream zis=zipFile.getInputStream(zipEntry.getName())){
            ByteStreams.copy(zis,os);
          }
           os.closeEntry();
        }
      }
    }
   }
  super.close();
  Path tmpZipFilePath=getTmpZipFilePath(zipFilePath);
  Files.copy(tmpZipFilePath,zipFilePath,StandardCopyOption.REPLACE_EXISTING);
  Files.delete(tmpZipFilePath);
}
Program: 38891
Project: 38891
Buggy source:
public synchronized int getInt(SUBSET subset,String id){
  if (subset == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (id == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Integer num=id2num.get(subset).get(id);
  if (num == null) {
    throw new IllegalStateException("String_Node_Str" + id + "String_Node_Str");
  }
  return num;
}

Fixed version (ground truth):
public synchronized int getInt(S subset,String id){
  if (subset == null) {
    throw createSubsetIsNullException();
  }
  if (id == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Integer num=id2num.get(subset).get(id);
  if (num == null) {
    throw new IllegalStateException("String_Node_Str" + id + "String_Node_Str");
  }
  return num;
}
Program: 38892
Project: 38892
Buggy source:
public synchronized int newInt(SUBSET subset,String id){
  if (subset == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (id == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Integer num=id2num.get(subset).get(id);
  if (num == null) {
    num=counter.get(subset);
    counter.put(subset,num + 1);
    id2num.get(subset).put(id,num);
    modified=true;
  }
  return num;
}

Fixed version (ground truth):
public synchronized int newInt(S subset,String id){
  if (subset == null) {
    throw createSubsetIsNullException();
  }
  if (id == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Integer num=id2num.get(subset).get(id);
  if (num == null) {
    num=counter.get(subset);
    counter.put(subset,num + 1);
    id2num.get(subset).put(id,num);
    modified=true;
  }
  return num;
}
Program: 38893
Project: 38893
Buggy source:
public synchronized boolean isMapped(SUBSET subset,String id){
  Map<String,Integer> numbers=id2num.get(subset);
  return numbers.containsKey(id);
}

Fixed version (ground truth):
public synchronized boolean isMapped(S subset,String id){
  Map<String,Integer> numbers=id2num.get(subset);
  return numbers.containsKey(id);
}
Program: 38894
Project: 38894
Buggy source:
public synchronized void reset(SUBSET subset){
  if (subset == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  id2num.put(subset,HashBiMap.<String,Integer>create());
  counter.put(subset,subset.getInitialValue());
}

Fixed version (ground truth):
public synchronized void reset(S subset){
  if (subset == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  id2num.put(subset,HashBiMap.<String,Integer>create());
  counter.put(subset,subset.getInitialValue());
}
Program: 38895
Project: 38895
Buggy source:
public synchronized String getId(SUBSET subset,int num){
  if (subset == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (num < subset.getInitialValue() || num >= counter.get(subset)) {
    throw new IllegalArgumentException("String_Node_Str" + num);
  }
  return id2num.get(subset).inverse().get(num);
}

Fixed version (ground truth):
public synchronized String getId(S subset,int num){
  if (subset == null) {
    throw createSubsetIsNullException();
  }
  if (num < subset.getInitialValue() || num >= counter.get(subset)) {
    throw new IllegalArgumentException("String_Node_Str" + num);
  }
  return id2num.get(subset).inverse().get(num);
}
Program: 38896
Project: 38896
Buggy source:
public StringToIntMapper(Class<SUBSET> clazz){
  this.clazz=clazz;
  id2num=new EnumMap<>(clazz);
  counter=new EnumMap<>(clazz);
  for (  SUBSET s : clazz.getEnumConstants()) {
    id2num.put(s,HashBiMap.<String,Integer>create());
    counter.put(s,s.getInitialValue());
  }
}

Fixed version (ground truth):
public StringToIntMapper(Class<S> clazz){
  this.clazz=clazz;
  id2num=new EnumMap<>(clazz);
  counter=new EnumMap<>(clazz);
  for (  S s : clazz.getEnumConstants()) {
    id2num.put(s,HashBiMap.<String,Integer>create());
    counter.put(s,s.getInitialValue());
  }
}
Program: 38897
Project: 38897
Buggy source:
@Override public void close() throws Exception {
  internalWriter.close();
}

Fixed version (ground truth):
@Override public void close(){
  try {
    internalWriter.close();
  }
 catch (  IOException e) {
    throw new UncheckedIOException(e);
  }
}
Program: 38898
Project: 38898
Buggy source:
private void checkSize(boolean last) throws IOException {
  if (last || buffer.size() > CHUNK_MAX_SIZE) {
    scheduler.sendCommonFile(new CommonFile(fileName,buffer.toByteArray(),chunk++,last));
    buffer.reset();
  }
}

Fixed version (ground truth):
private void checkSize(boolean last){
  if (last || buffer.size() > CHUNK_MAX_SIZE) {
    scheduler.sendCommonFile(new CommonFile(fileName,buffer.toByteArray(),chunk++,last));
    buffer.reset();
  }
}
Program: 38900
Project: 38900
Buggy source:
public MpiComputationManager(Path localDir,MpiJobScheduler scheduler,MpiStatistics statistics,MpiExecutorContext executorContext) throws IOException, InterruptedException {
  this.localDir=Objects.requireNonNull(localDir);
  this.statistics=Objects.requireNonNull(statistics);
  this.executorContext=Objects.requireNonNull(executorContext);
  this.scheduler=scheduler;
  if (executorContext.getMonitorExecutor() != null) {
    busyCoresPrintTask=executorContext.getMonitorExecutor().scheduleAtFixedRate(new Runnable(){
      @Override public void run(){
        LOGGER.info("String_Node_Str",scheduler.getResources().getBusyCores(),scheduler.getResources().getAvailableCores(),((float)scheduler.getStartedTasksAndReset()) / LOG_DELAY);
      }
    }
,0,LOG_DELAY,TimeUnit.SECONDS);
  }
}

Fixed version (ground truth):
public MpiComputationManager(Path localDir,MpiJobScheduler scheduler,MpiStatistics statistics,MpiExecutorContext executorContext){
  this.localDir=Objects.requireNonNull(localDir);
  this.statistics=Objects.requireNonNull(statistics);
  this.executorContext=Objects.requireNonNull(executorContext);
  this.scheduler=scheduler;
  if (executorContext.getMonitorExecutor() != null) {
    busyCoresPrintTask=executorContext.getMonitorExecutor().scheduleAtFixedRate(() -> LOGGER.info("String_Node_Str",scheduler.getResources().getBusyCores(),scheduler.getResources().getAvailableCores(),((float)scheduler.getStartedTasksAndReset()) / LOG_DELAY),0,LOG_DELAY,TimeUnit.SECONDS);
  }
}
Program: 38901
Project: 38901
Buggy source:
@Override public OutputStream newCommonFile(final String fileName) throws IOException {
  return new OutputStream(){
    private final ByteArrayOutputStream buffer=new ByteArrayOutputStream();
    private int chunk=0;
    private void checkSize(    boolean last) throws IOException {
      if (last || buffer.size() > CHUNK_MAX_SIZE) {
        scheduler.sendCommonFile(new CommonFile(fileName,buffer.toByteArray(),chunk++,last));
        buffer.reset();
      }
    }
    @Override public void write(    int b) throws IOException {
      buffer.write(b);
      checkSize(false);
    }
    @Override public void write(    byte[] b) throws IOException {
      buffer.write(b);
      checkSize(false);
    }
    @Override public void write(    byte[] b,    int off,    int len) throws IOException {
      buffer.write(b,off,len);
      checkSize(false);
    }
    @Override public void flush() throws IOException {
      buffer.flush();
    }
    @Override public void close() throws IOException {
      buffer.close();
      checkSize(true);
    }
  }
;
}

Fixed version (ground truth):
@Override public OutputStream newCommonFile(final String fileName) throws IOException {
  return new OutputStream(){
    private final ByteArrayOutputStream buffer=new ByteArrayOutputStream();
    private int chunk=0;
    private void checkSize(    boolean last){
      if (last || buffer.size() > CHUNK_MAX_SIZE) {
        scheduler.sendCommonFile(new CommonFile(fileName,buffer.toByteArray(),chunk++,last));
        buffer.reset();
      }
    }
    @Override public void write(    int b) throws IOException {
      buffer.write(b);
      checkSize(false);
    }
    @Override public void write(    byte[] b) throws IOException {
      buffer.write(b);
      checkSize(false);
    }
    @Override public void write(    byte[] b,    int off,    int len) throws IOException {
      buffer.write(b,off,len);
      checkSize(false);
    }
    @Override public void flush() throws IOException {
      buffer.flush();
    }
    @Override public void close() throws IOException {
      buffer.close();
      checkSize(true);
    }
  }
;
}
Program: 38902
Project: 38902
Buggy source:
@Override public void close() throws Exception {
  scheduler.shutdown();
  statistics.close();
  if (busyCoresPrintTask != null) {
    busyCoresPrintTask.cancel(true);
  }
}

Fixed version (ground truth):
@Override public void close(){
  try {
    scheduler.shutdown();
  }
 catch (  Exception e) {
    LOGGER.error(e.toString(),e);
  }
  try {
    statistics.close();
  }
 catch (  Exception e) {
    LOGGER.error(e.toString(),e);
  }
  if (busyCoresPrintTask != null) {
    busyCoresPrintTask.cancel(true);
  }
  try {
    executorContext.shutdown();
  }
 catch (  Exception e) {
    LOGGER.error(e.toString(),e);
  }
}
Program: 38903
Project: 38903
Buggy source:
public static ComputationManager createMpiComputationManager(CommandLine line,FileSystem fileSystem){
  Path tmpDir=fileSystem.getPath(line.hasOption("String_Node_Str") ? line.getOptionValue("String_Node_Str") : System.getProperty("String_Node_Str"));
  Path statisticsDbDir=line.hasOption("String_Node_Str") ? fileSystem.getPath(line.getOptionValue("String_Node_Str")) : null;
  String statisticsDbName=line.hasOption("String_Node_Str") ? line.getOptionValue("String_Node_Str") : null;
  int coresPerRank=Integer.parseInt(line.getOptionValue("String_Node_Str"));
  boolean verbose=line.hasOption("String_Node_Str");
  Path stdOutArchive=line.hasOption("String_Node_Str") ? fileSystem.getPath(line.getOptionValue("String_Node_Str")) : null;
  ComponentDefaultConfig config=ComponentDefaultConfig.load();
  MpiExecutorContext mpiExecutorContext=new MpiExecutorContext();
  MpiStatisticsFactory statisticsFactory=createMpiStatisticsFactory(config,statisticsDbDir,statisticsDbName);
  try {
    MpiStatistics statistics=statisticsFactory.create(statisticsDbDir,statisticsDbName);
    return new MpiComputationManager(tmpDir,statistics,mpiExecutorContext,coresPerRank,verbose,stdOutArchive){
      @Override public void close() throws Exception {
        try {
          super.close();
        }
 catch (        Exception e) {
          LOGGER.error(e.toString(),e);
        }
        try {
          statistics.close();
        }
 catch (        Exception e) {
          LOGGER.error(e.toString(),e);
        }
        try {
          mpiExecutorContext.shutdown();
        }
 catch (        Exception e) {
          LOGGER.error(e.toString(),e);
        }
      }
    }
;
  }
 catch (  IOException e) {
    throw new UncheckedIOException(e);
  }
catch (  InterruptedException e) {
    throw new UncheckedInterruptedException(e);
  }
}

Fixed version (ground truth):
public static ComputationManager createMpiComputationManager(CommandLine line,FileSystem fileSystem){
  Path tmpDir=fileSystem.getPath(line.hasOption("String_Node_Str") ? line.getOptionValue("String_Node_Str") : System.getProperty("String_Node_Str"));
  Path statisticsDbDir=line.hasOption("String_Node_Str") ? fileSystem.getPath(line.getOptionValue("String_Node_Str")) : null;
  String statisticsDbName=line.hasOption("String_Node_Str") ? line.getOptionValue("String_Node_Str") : null;
  int coresPerRank=Integer.parseInt(line.getOptionValue("String_Node_Str"));
  boolean verbose=line.hasOption("String_Node_Str");
  Path stdOutArchive=line.hasOption("String_Node_Str") ? fileSystem.getPath(line.getOptionValue("String_Node_Str")) : null;
  ComponentDefaultConfig config=ComponentDefaultConfig.load();
  MpiStatisticsFactory statisticsFactory=createMpiStatisticsFactory(config,statisticsDbDir,statisticsDbName);
  try {
    return new MpiComputationManager(tmpDir,statisticsFactory.create(statisticsDbDir,statisticsDbName),new MpiExecutorContext(),coresPerRank,verbose,stdOutArchive);
  }
 catch (  IOException e) {
    throw new UncheckedIOException(e);
  }
catch (  InterruptedException e) {
    throw new UncheckedInterruptedException(e);
  }
}
Program: 38904
Project: 38904
Buggy source:
@Override public void close() throws Exception {
}

Fixed version (ground truth):
@Override public void close(){
}
Program: 38905
Project: 38905
Buggy source:
public static TsoGeneratorSpeedAutomaton fromXml(String contingencyId,XMLStreamReader xmlsr) throws XMLStreamException {
  boolean under=false;
  boolean over=false;
  String text=null;
  List<String> onUnderSpeedDiconnectedGenerators=new ArrayList<>();
  List<String> onOverSpeedDiconnectedGenerators=new ArrayList<>();
  while (xmlsr.hasNext()) {
    int eventType=xmlsr.next();
switch (eventType) {
case XMLEvent.CHARACTERS:
      text=xmlsr.getText();
    break;
case XMLEvent.START_ELEMENT:
switch (xmlsr.getLocalName()) {
case "String_Node_Str":
    under=true;
  break;
case "String_Node_Str":
over=true;
break;
}
break;
case XMLEvent.END_ELEMENT:
switch (xmlsr.getLocalName()) {
case "String_Node_Str":
under=false;
break;
case "String_Node_Str":
over=false;
break;
case "String_Node_Str":
if (under) {
onUnderSpeedDiconnectedGenerators.add(text);
}
 else if (over) {
onOverSpeedDiconnectedGenerators.add(text);
}
 else {
throw new AssertionError();
}
break;
case "String_Node_Str":
return new TsoGeneratorSpeedAutomaton(contingencyId,onUnderSpeedDiconnectedGenerators,onOverSpeedDiconnectedGenerators);
}
break;
}
}
throw new AssertionError("String_Node_Str");
}

Fixed version (ground truth):
public static TsoGeneratorSpeedAutomaton fromXml(String contingencyId,XMLStreamReader xmlsr) throws XMLStreamException {
  LimitsXmlParsingState state=null;
  String text=null;
  List<String> onUnderSpeedDiconnectedGenerators=new ArrayList<>();
  List<String> onOverSpeedDiconnectedGenerators=new ArrayList<>();
  while (xmlsr.hasNext()) {
    int eventType=xmlsr.next();
switch (eventType) {
case XMLEvent.CHARACTERS:
      text=xmlsr.getText();
    break;
case XMLEvent.START_ELEMENT:
switch (xmlsr.getLocalName()) {
case ON_UNDER_SPEED_DISCONNECTED_GENERATORS:
    state=LimitsXmlParsingState.UNDER;
  break;
case ON_OVER_SPEED_DISCONNECTED_GENERATORS:
state=LimitsXmlParsingState.OVER;
break;
}
break;
case XMLEvent.END_ELEMENT:
switch (xmlsr.getLocalName()) {
case ON_UNDER_SPEED_DISCONNECTED_GENERATORS:
case ON_OVER_SPEED_DISCONNECTED_GENERATORS:
state=null;
break;
case "String_Node_Str":
LimitsXmlParsingState.addGenerator(state,text,onUnderSpeedDiconnectedGenerators,onOverSpeedDiconnectedGenerators);
break;
case "String_Node_Str":
return new TsoGeneratorSpeedAutomaton(contingencyId,onUnderSpeedDiconnectedGenerators,onOverSpeedDiconnectedGenerators);
}
break;
}
}
throw new AssertionError("String_Node_Str");
}
Program: 38906
Project: 38906
Buggy source:
public static TsoGeneratorVoltageAutomaton fromXml(String contingencyId,XMLStreamReader xmlsr) throws XMLStreamException {
  boolean under=false;
  boolean over=false;
  String text=null;
  List<String> onUnderVoltageDiconnectedGenerators=new ArrayList<>();
  List<String> onOverVoltageDiconnectedGenerators=new ArrayList<>();
  while (xmlsr.hasNext()) {
    int eventType=xmlsr.next();
switch (eventType) {
case XMLEvent.CHARACTERS:
      text=xmlsr.getText();
    break;
case XMLEvent.START_ELEMENT:
switch (xmlsr.getLocalName()) {
case "String_Node_Str":
    under=true;
  break;
case "String_Node_Str":
over=true;
break;
}
break;
case XMLEvent.END_ELEMENT:
switch (xmlsr.getLocalName()) {
case "String_Node_Str":
under=false;
break;
case "String_Node_Str":
over=false;
break;
case "String_Node_Str":
if (under) {
onUnderVoltageDiconnectedGenerators.add(text);
}
 else if (over) {
onOverVoltageDiconnectedGenerators.add(text);
}
 else {
throw new AssertionError();
}
break;
case "String_Node_Str":
return new TsoGeneratorVoltageAutomaton(contingencyId,onUnderVoltageDiconnectedGenerators,onOverVoltageDiconnectedGenerators);
}
break;
}
}
throw new AssertionError("String_Node_Str");
}

Fixed version (ground truth):
public static TsoGeneratorVoltageAutomaton fromXml(String contingencyId,XMLStreamReader xmlsr) throws XMLStreamException {
  LimitsXmlParsingState state=null;
  String text=null;
  List<String> onUnderVoltageDiconnectedGenerators=new ArrayList<>();
  List<String> onOverVoltageDiconnectedGenerators=new ArrayList<>();
  while (xmlsr.hasNext()) {
    int eventType=xmlsr.next();
switch (eventType) {
case XMLEvent.CHARACTERS:
      text=xmlsr.getText();
    break;
case XMLEvent.START_ELEMENT:
switch (xmlsr.getLocalName()) {
case ON_UNDER_VOLTAGE_DISCONNECTED_GENERATORS:
    state=LimitsXmlParsingState.UNDER;
  break;
case ON_OVER_VOLTAGE_DISCONNECTED_GENERATORS:
state=LimitsXmlParsingState.OVER;
break;
}
break;
case XMLEvent.END_ELEMENT:
switch (xmlsr.getLocalName()) {
case ON_UNDER_VOLTAGE_DISCONNECTED_GENERATORS:
case ON_OVER_VOLTAGE_DISCONNECTED_GENERATORS:
state=null;
break;
case "String_Node_Str":
LimitsXmlParsingState.addGenerator(state,text,onUnderVoltageDiconnectedGenerators,onOverVoltageDiconnectedGenerators);
break;
case "String_Node_Str":
return new TsoGeneratorVoltageAutomaton(contingencyId,onUnderVoltageDiconnectedGenerators,onOverVoltageDiconnectedGenerators);
}
break;
}
}
throw new AssertionError("String_Node_Str");
}
Program: 38907
Project: 38907
Buggy source:
private UndirectedGraph<UcteNodeCode,Object> createSubstationGraph(UcteNetwork network){
  UndirectedGraph<UcteNodeCode,Object> graph=new Pseudograph<>(Object.class);
  for (  UcteNode node : network.getNodes()) {
    graph.addVertex(node.getCode());
  }
  Multimap<String,UcteNode> nodesByGeographicalSpot=Multimaps.index(network.getNodes(),new Function<UcteNode,String>(){
    @Override public String apply(    UcteNode node){
      return node.getCode().getGeographicalSpot();
    }
  }
);
  for (  Map.Entry<String,Collection<UcteNode>> entry : nodesByGeographicalSpot.asMap().entrySet()) {
    for (    UcteNode n1 : entry.getValue()) {
      for (      UcteNode n2 : entry.getValue()) {
        if (n1 != n2) {
          graph.addEdge(n1.getCode(),n2.getCode());
        }
      }
    }
  }
  for (  UcteTransformer tfo : network.getTransformers()) {
    UcteNodeCode nodeCode1=tfo.getId().getNodeCode1();
    UcteNodeCode nodeCode2=tfo.getId().getNodeCode2();
    graph.addEdge(nodeCode1,nodeCode2);
  }
  for (  UcteLine l : network.getLines()) {
    UcteNodeCode nodeCode1=l.getId().getNodeCode1();
    UcteNodeCode nodeCode2=l.getId().getNodeCode2();
    if (l.getStatus() == UcteElementStatus.BUSBAR_COUPLER_IN_OPERATION || l.getStatus() == UcteElementStatus.BUSBAR_COUPLER_OUT_OF_OPERATION) {
      graph.addEdge(nodeCode1,nodeCode2);
    }
 else {
      double z=Math.hypot(l.getResistance(),l.getReactance());
      if (z < lineMinZ) {
        graph.addEdge(nodeCode1,nodeCode2);
      }
    }
  }
  return graph;
}

Fixed version (ground truth):
private UndirectedGraph<UcteNodeCode,Object> createSubstationGraph(UcteNetwork network){
  UndirectedGraph<UcteNodeCode,Object> graph=new Pseudograph<>(Object.class);
  for (  UcteNode node : network.getNodes()) {
    graph.addVertex(node.getCode());
  }
  Multimap<String,UcteNode> nodesByGeographicalSpot=Multimaps.index(network.getNodes(),node -> node.getCode().getGeographicalSpot());
  for (  Map.Entry<String,Collection<UcteNode>> entry : nodesByGeographicalSpot.asMap().entrySet()) {
    for (    UcteNode n1 : entry.getValue()) {
      for (      UcteNode n2 : entry.getValue()) {
        if (n1 != n2) {
          graph.addEdge(n1.getCode(),n2.getCode());
        }
      }
    }
  }
  for (  UcteTransformer tfo : network.getTransformers()) {
    UcteNodeCode nodeCode1=tfo.getId().getNodeCode1();
    UcteNodeCode nodeCode2=tfo.getId().getNodeCode2();
    graph.addEdge(nodeCode1,nodeCode2);
  }
  for (  UcteLine l : network.getLines()) {
    UcteNodeCode nodeCode1=l.getId().getNodeCode1();
    UcteNodeCode nodeCode2=l.getId().getNodeCode2();
    if (l.getStatus() == UcteElementStatus.BUSBAR_COUPLER_IN_OPERATION || l.getStatus() == UcteElementStatus.BUSBAR_COUPLER_OUT_OF_OPERATION) {
      graph.addEdge(nodeCode1,nodeCode2);
    }
 else {
      double z=Math.hypot(l.getResistance(),l.getReactance());
      if (z < lineMinZ) {
        graph.addEdge(nodeCode1,nodeCode2);
      }
    }
  }
  return graph;
}
Program: 38910
Project: 38910
Buggy source:
@Override public HalfLineImpl setXnodeQ(float xnodeQ){
  this.xnodeQ=xnodeQ;
  return null;
}

Fixed version (ground truth):
@Override public HalfLineImpl setXnodeQ(float xnodeQ){
  this.xnodeQ=xnodeQ;
  return this;
}
Program: 38911
Project: 38911
Buggy source:
public void readCsv(BufferedReader reader,char separator){
  try {
    String strSep=Character.toString(separator);
    String line;
    while ((line=reader.readLine()) != null) {
      String trimmedLine=line.trim();
      if (trimmedLine.isEmpty()) {
        continue;
      }
      String[] tokens=trimmedLine.split(strSep);
      if (tokens.length != 2) {
        LOGGER.warn("String_Node_Str",trimmedLine);
        continue;
      }
      mapping.put(tokens[0],tokens[1]);
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void readCsv(BufferedReader reader,char separator){
  CsvListReader csvReader=new CsvListReader(reader,createPreference(separator));
  List<String> nextLine;
  try {
    while ((nextLine=csvReader.read()) != null) {
      if (nextLine.size() != 2) {
        throw new RuntimeException("String_Node_Str" + nextLine + "String_Node_Str");
      }
      mapping.put(nextLine.get(0),nextLine.get(1));
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 38912
Project: 38912
Buggy source:
public void writeCsv(BufferedWriter writer,char separator){
  mapping.forEach((s,s2) -> {
    try {
      writer.write(s);
      writer.write(separator);
      writer.write(s2);
      writer.newLine();
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
);
}

Fixed version (ground truth):
public void writeCsv(BufferedWriter writer,char separator){
  CsvListWriter csvWriter=new CsvListWriter(writer,createPreference(separator));
  String[] nextLine=new String[2];
  try {
    try {
      for (      Map.Entry<String,String> e : mapping.entrySet()) {
        nextLine[0]=e.getKey();
        nextLine[1]=e.getValue();
        csvWriter.write(nextLine);
      }
    }
  finally {
      csvWriter.flush();
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 38913
Project: 38913
Buggy source:
@Test public void invalidFileTest() throws IOException {
  String csv=String.join(System.lineSeparator(),"String_Node_Str","String_Node_Str","String_Node_Str");
  StringAnonymizer anonymizer=fromCsv(csv);
  assertEquals(1,anonymizer.getStringCount());
}

Fixed version (ground truth):
@Test public void invalidFileTest() throws IOException {
  String csv=String.join(System.lineSeparator(),"String_Node_Str","String_Node_Str");
  StringAnonymizer anonymizer=fromCsv(csv);
  assertEquals(1,anonymizer.getStringCount());
}
Program: 38914
Project: 38914
Buggy source:
public void readCsv(BufferedReader reader,char separator){
  try {
    String strSep=Character.toString(separator);
    String line;
    while ((line=reader.readLine()) != null) {
      String[] tokens=line.split(strSep);
      mapping.put(tokens[0],tokens[1]);
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void readCsv(BufferedReader reader,char separator){
  try {
    String strSep=Character.toString(separator);
    String line;
    while ((line=reader.readLine()) != null) {
      String trimmedLine=line.trim();
      if (trimmedLine.isEmpty()) {
        continue;
      }
      String[] tokens=trimmedLine.split(strSep);
      if (tokens.length != 2) {
        LOGGER.warn("String_Node_Str",trimmedLine);
        continue;
      }
      mapping.put(tokens[0],tokens[1]);
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 38915
Project: 38915
Buggy source:
Integer getOptionalIntProperty(String name);

Fixed version (ground truth):
@Deprecated Integer getOptionalIntProperty(String name);
Program: 38916
Project: 38916
Buggy source:
Boolean getOptinalBooleanProperty(String name);

Fixed version (ground truth):
@Deprecated Boolean getOptinalBooleanProperty(String name);
Program: 38917
Project: 38917
Buggy source:
public static Table<String,String,Float> parseMatrix(Reader reader) throws IOException {
  Table<String,String,Float> table=HashBasedTable.create();
  try (ICsvListReader csvReader=new CsvListReader(reader,CsvPreference.STANDARD_PREFERENCE)){
    List<String> columnHeaders=csvReader.read();
    List<String> row;
    while ((row=csvReader.read()) != null) {
      String rowHeader=row.get(0);
      for (int i=1; i < row.size(); i++) {
        String columnHeader=columnHeaders.get(i);
        String value=row.get(i);
        table.put(rowHeader,columnHeader,value == null ? Float.NaN : Float.valueOf(value));
      }
    }
  }
   return table;
}

Fixed version (ground truth):
public static Table<String,String,Float> parseMatrix(Reader reader) throws IOException {
  Table<String,String,Float> table=HashBasedTable.create();
  try (ICsvListReader csvReader=new CsvListReader(reader,CsvPreference.STANDARD_PREFERENCE)){
    List<String> columnHeaders=csvReader.read();
    List<String> row;
    while ((row=csvReader.read()) != null) {
      String rowHeader=row.get(0);
      for (int i=1; i < row.size(); i++) {
        String columnHeader=columnHeaders.get(i);
        String value=row.get(i);
        table.put(rowHeader,columnHeader,value == null ? Float.NaN : Float.parseFloat(value));
      }
    }
  }
   return table;
}
Program: 38918
Project: 38918
Buggy source:
public AsciiTableFormatter(String title,Column... columns){
  this(new OutputStreamWriter(System.out),title,TableFormatterConfig.load(),columns);
}

Fixed version (ground truth):
public AsciiTableFormatter(String title,Column... columns){
  this(new OutputStreamWriter(System.out,StandardCharsets.UTF_8),title,TableFormatterConfig.load(),columns);
}
Program: 38920
Project: 38920
Buggy source:
@Test public void testCsv() throws IOException {
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  TableFormatterConfig config=new TableFormatterConfig(Locale.US,';',"String_Node_Str",true,true);
  CsvTableFormatterFactory factory=new CsvTableFormatterFactory();
  try (TableFormatter formatter=factory.create(new OutputStreamWriter(bos),"String_Node_Str",config,COLUMNS)){
    write(formatter);
  }
   assertEquals(new String(bos.toByteArray(),StandardCharsets.UTF_8),"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
@Test public void testCsv() throws IOException {
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  TableFormatterConfig config=new TableFormatterConfig(Locale.US,';',"String_Node_Str",true,true);
  CsvTableFormatterFactory factory=new CsvTableFormatterFactory();
  try (TableFormatter formatter=factory.create(new OutputStreamWriter(bos,StandardCharsets.UTF_8),"String_Node_Str",config,COLUMNS)){
    write(formatter);
  }
   assertEquals(new String(bos.toByteArray(),StandardCharsets.UTF_8),"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
}
Program: 38921
Project: 38921
Buggy source:
@Test public void testAcsii() throws IOException {
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  TableFormatterConfig config=new TableFormatterConfig(Locale.US,"String_Node_Str");
  AsciiTableFormatterFactory factory=new AsciiTableFormatterFactory();
  try (TableFormatter formatter=factory.create(new OutputStreamWriter(bos),"String_Node_Str",config,COLUMNS)){
    write(formatter);
  }
   assertEquals(new String(bos.toByteArray(),StandardCharsets.UTF_8),"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
@Test public void testAcsii() throws IOException {
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  TableFormatterConfig config=new TableFormatterConfig(Locale.US,"String_Node_Str");
  AsciiTableFormatterFactory factory=new AsciiTableFormatterFactory();
  try (TableFormatter formatter=factory.create(new OutputStreamWriter(bos,StandardCharsets.UTF_8),"String_Node_Str",config,COLUMNS)){
    write(formatter);
  }
   assertEquals(new String(bos.toByteArray(),StandardCharsets.UTF_8),"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 38922
Project: 38922
Buggy source:
public static Object readParameter(String format,Properties parameters,Parameter configuredParameter,ParameterDefaultValueConfig defaultValueConfig){
  Object value=null;
  if (parameters != null) {
    MapModuleConfig moduleConfig=new MapModuleConfig(parameters);
switch (configuredParameter.getType()) {
case BOOLEAN:
      value=moduleConfig.getOptinalBooleanProperty(configuredParameter.getName());
    break;
case STRING:
  value=moduleConfig.getStringProperty(configuredParameter.getName(),null);
break;
case STRING_LIST:
value=moduleConfig.getStringListProperty(configuredParameter.getName(),null);
break;
default :
throw new AssertionError();
}
}
if (value == null) {
value=defaultValueConfig.getValue(format,configuredParameter);
}
return value;
}

Fixed version (ground truth):
public static Object readParameter(String format,Properties parameters,Parameter configuredParameter,ParameterDefaultValueConfig defaultValueConfig){
  Object value=null;
  if (parameters != null) {
    MapModuleConfig moduleConfig=new MapModuleConfig(parameters);
switch (configuredParameter.getType()) {
case BOOLEAN:
      value=moduleConfig.getOptionalBooleanProperty(configuredParameter.getName()).get();
    break;
case STRING:
  value=moduleConfig.getStringProperty(configuredParameter.getName(),null);
break;
case STRING_LIST:
value=moduleConfig.getStringListProperty(configuredParameter.getName(),null);
break;
default :
throw new AssertionError();
}
}
if (value == null) {
value=defaultValueConfig.getValue(format,configuredParameter);
}
return value;
}
Program: 38923
Project: 38923
Buggy source:
public Terminal getTerminal(String voltageLevelId){
  Objects.requireNonNull(voltageLevelId);
  boolean side1=getTerminal1().getVoltageLevel().getId().equals(voltageLevelId);
  boolean side2=getTerminal2().getVoltageLevel().getId().equals(voltageLevelId);
  if (side1) {
    return getTerminal1();
  }
 else   if (side2) {
    return getTerminal2();
  }
 else   if (side1 && side2) {
    throw new RuntimeException("String_Node_Str" + voltageLevelId);
  }
 else {
    throw new RuntimeException("String_Node_Str" + voltageLevelId);
  }
}

Fixed version (ground truth):
public Terminal getTerminal(String voltageLevelId){
  Objects.requireNonNull(voltageLevelId);
  boolean side1=getTerminal1().getVoltageLevel().getId().equals(voltageLevelId);
  boolean side2=getTerminal2().getVoltageLevel().getId().equals(voltageLevelId);
  if (side1 && side2) {
    throw new RuntimeException("String_Node_Str" + voltageLevelId);
  }
 else   if (side1) {
    return getTerminal1();
  }
 else   if (side2) {
    return getTerminal2();
  }
 else {
    throw new RuntimeException("String_Node_Str" + voltageLevelId);
  }
}