Program: 73893
Project: 73893
Buggy source:
/** 
 * Resolve the properties of the given top-level container, subject to the given constraint list.
 * @param toplevel The top-level container
 * @param toplevelHelper Must be toplevel.getHelper()
 * @param constraintList The constraint list that we are solving
 * @throws TypeConflictException If an unacceptable solution is reached
 * @throws PropertyResolutionException If constraints are unsatisfiable
 */
protected void _resolveProperties(NamedObj toplevel,PropertyConstraintHelper toplevelHelper,List<Inequality> constraintList) throws TypeConflictException, PropertyResolutionException {
  Writer writer=null;
  List<Inequality> conflicts=new LinkedList<Inequality>();
  List<Inequality> unacceptable=new LinkedList<Inequality>();
  try {
    if (constraintList.size() > 0) {
      CPO cpo=getLattice();
      InequalitySolver solver=new InequalitySolver(cpo,this);
      solver.addInequalities(constraintList.iterator());
      _constraintManager.setConstraints(constraintList);
      getStats().put("String_Node_Str",constraintList.size());
      getStats().put("String_Node_Str",_propertyTermManager.terms().size());
      File file=null;
      Date date=new Date();
      String timestamp=date.toString().replace("String_Node_Str","String_Node_Str");
      String logFilename=getContainer().getName() + "String_Node_Str" + getUseCaseName()+ "String_Node_Str"+ timestamp.replace("String_Node_Str","String_Node_Str")+ "String_Node_Str";
      if (super.isResolve() && isLogMode()) {
        String directoryPath=logDirectory.getExpression();
        directoryPath+=directoryPath.endsWith("String_Node_Str") || directoryPath.endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str";
        if (directoryPath.startsWith("String_Node_Str")) {
          URI directory=new File(URIAttribute.getModelURI(this)).getParentFile().toURI();
          file=FileUtilities.nameToFile(directoryPath.substring(11) + logFilename,directory);
        }
 else {
          if (!logDirectory.asFile().exists()) {
            if (!logDirectory.asFile().mkdirs()) {
              throw new IllegalActionException(this,"String_Node_Str" + logDirectory.asFile().getAbsolutePath() + "String_Node_Str");
            }
          }
          file=FileUtilities.nameToFile(logFilename,logDirectory.asFile().toURI());
        }
        try {
          if (!file.exists()) {
            if (!file.getParentFile().exists()) {
              if (!file.getParentFile().mkdirs()) {
                throw new IllegalActionException(this,"String_Node_Str" + file.getParentFile().getAbsolutePath() + "String_Node_Str");
              }
            }
            if (!file.createNewFile()) {
              throw new IllegalActionException(this,"String_Node_Str" + file.getAbsolutePath() + "String_Node_Str");
            }
          }
          writer=new FileWriter(file);
          writer.write(_getStatsAsString("String_Node_Str"));
          writer.write(_getConstraintsAsLogFileString(constraintList,"String_Node_Str"));
        }
 catch (        IOException ex) {
          throw new PropertyResolutionException(this,ex,"String_Node_Str" + file.getAbsolutePath() + "String_Node_Str");
        }
      }
      if (super.isResolve() && isLogMode()) {
        String constraintFilename=_getTrainedConstraintFilename() + "String_Node_Str";
        _logHelperConstraints(toplevelHelper);
        _updateConstraintFile(constraintFilename);
      }
      if (!isCollectConstraints()) {
        if (solvingFixedPoint.stringValue().equals("String_Node_Str")) {
          solver.solveGreatest(isInitializeSolver());
        }
 else {
          solver.solveLeast(isInitializeSolver());
        }
      }
      if (super.isResolve() && isLogMode()) {
        try {
          writer.write(_getConstraintsAsLogFileString(constraintList,"String_Node_Str"));
          writer.close();
        }
 catch (        IOException ex) {
          throw new PropertyResolutionException(this,ex,"String_Node_Str" + file.getAbsolutePath() + "String_Node_Str");
        }
      }
      for (      Inequality inequality : constraintList) {
        if (!inequality.isSatisfied(_lattice)) {
          conflicts.add(inequality);
        }
 else {
          boolean isAcceptable=true;
          InequalityTerm[] lesserVariables=inequality.getLesserTerm().getVariables();
          InequalityTerm[] greaterVariables=inequality.getGreaterTerm().getVariables();
          for (          InequalityTerm variable : lesserVariables) {
            if (!variable.isValueAcceptable()) {
              unacceptable.add(inequality);
              isAcceptable=false;
              break;
            }
          }
          if (isAcceptable) {
            for (            InequalityTerm variable : greaterVariables) {
              if (!variable.isValueAcceptable()) {
                unacceptable.add(inequality);
                break;
              }
            }
          }
        }
      }
    }
    if (!isInitializeSolver() && !isCollectConstraints()) {
      if (conflicts.size() > 0) {
        throw new PropertyResolutionException(this,toplevel(),"String_Node_Str" + toplevel().getFullName() + "String_Node_Str"+ conflicts);
      }
      if (unacceptable.size() > 0) {
        throw new TypeConflictException(unacceptable,"String_Node_Str" + toplevel.getFullName() + "String_Node_Str");
      }
    }
  }
 catch (  IllegalActionException ex) {
    throw new PropertyResolutionException(this,toplevel,ex,"String_Node_Str" + "String_Node_Str");
  }
 finally {
    if (writer != null) {
      try {
        writer.close();
      }
 catch (      IOException ex) {
        throw new PropertyResolutionException(this,toplevel(),ex,"String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Resolve the properties of the given top-level container, subject to the given constraint list.
 * @param toplevel The top-level container
 * @param toplevelHelper Must be toplevel.getHelper()
 * @param constraintList The constraint list that we are solving
 * @throws TypeConflictException If an unacceptable solution is reached
 * @throws PropertyResolutionException If constraints are unsatisfiable
 */
protected void _resolveProperties(NamedObj toplevel,PropertyConstraintHelper toplevelHelper,List<Inequality> constraintList) throws TypeConflictException, PropertyResolutionException {
  Writer writer=null;
  List<Inequality> conflicts=new LinkedList<Inequality>();
  List<Inequality> unacceptable=new LinkedList<Inequality>();
  try {
    if (constraintList.size() > 0) {
      CPO cpo=getLattice();
      ptolemy.graph.InequalitySolver solver=new ptolemy.graph.InequalitySolver(cpo);
      solver.addInequalities(constraintList.iterator());
      _constraintManager.setConstraints(constraintList);
      getStats().put("String_Node_Str",constraintList.size());
      getStats().put("String_Node_Str",_propertyTermManager.terms().size());
      File file=null;
      Date date=new Date();
      String timestamp=date.toString().replace("String_Node_Str","String_Node_Str");
      String logFilename=getContainer().getName() + "String_Node_Str" + getUseCaseName()+ "String_Node_Str"+ timestamp.replace("String_Node_Str","String_Node_Str")+ "String_Node_Str";
      if (super.isResolve() && isLogMode()) {
        String directoryPath=logDirectory.getExpression();
        directoryPath+=directoryPath.endsWith("String_Node_Str") || directoryPath.endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str";
        if (directoryPath.startsWith("String_Node_Str")) {
          URI directory=new File(URIAttribute.getModelURI(this)).getParentFile().toURI();
          file=FileUtilities.nameToFile(directoryPath.substring(11) + logFilename,directory);
        }
 else {
          if (!logDirectory.asFile().exists()) {
            if (!logDirectory.asFile().mkdirs()) {
              throw new IllegalActionException(this,"String_Node_Str" + logDirectory.asFile().getAbsolutePath() + "String_Node_Str");
            }
          }
          file=FileUtilities.nameToFile(logFilename,logDirectory.asFile().toURI());
        }
        try {
          if (!file.exists()) {
            if (!file.getParentFile().exists()) {
              if (!file.getParentFile().mkdirs()) {
                throw new IllegalActionException(this,"String_Node_Str" + file.getParentFile().getAbsolutePath() + "String_Node_Str");
              }
            }
            if (!file.createNewFile()) {
              throw new IllegalActionException(this,"String_Node_Str" + file.getAbsolutePath() + "String_Node_Str");
            }
          }
          writer=new FileWriter(file);
          writer.write(_getStatsAsString("String_Node_Str"));
          writer.write(_getConstraintsAsLogFileString(constraintList,"String_Node_Str"));
        }
 catch (        IOException ex) {
          throw new PropertyResolutionException(this,ex,"String_Node_Str" + file.getAbsolutePath() + "String_Node_Str");
        }
      }
      if (super.isResolve() && isLogMode()) {
        String constraintFilename=_getTrainedConstraintFilename() + "String_Node_Str";
        _logHelperConstraints(toplevelHelper);
        _updateConstraintFile(constraintFilename);
      }
      if (!isCollectConstraints()) {
        if (solvingFixedPoint.stringValue().equals("String_Node_Str")) {
          solver.solveGreatest();
        }
 else {
          solver.solveLeast();
        }
      }
      if (super.isResolve() && isLogMode()) {
        try {
          writer.write(_getConstraintsAsLogFileString(constraintList,"String_Node_Str"));
          writer.close();
        }
 catch (        IOException ex) {
          throw new PropertyResolutionException(this,ex,"String_Node_Str" + file.getAbsolutePath() + "String_Node_Str");
        }
      }
      for (      Inequality inequality : constraintList) {
        if (!inequality.isSatisfied(_lattice)) {
          conflicts.add(inequality);
        }
 else {
          boolean isAcceptable=true;
          InequalityTerm[] lesserVariables=inequality.getLesserTerm().getVariables();
          InequalityTerm[] greaterVariables=inequality.getGreaterTerm().getVariables();
          for (          InequalityTerm variable : lesserVariables) {
            if (!variable.isValueAcceptable()) {
              unacceptable.add(inequality);
              isAcceptable=false;
              break;
            }
          }
          if (isAcceptable) {
            for (            InequalityTerm variable : greaterVariables) {
              if (!variable.isValueAcceptable()) {
                unacceptable.add(inequality);
                break;
              }
            }
          }
        }
      }
    }
    if (!isInitializeSolver() && !isCollectConstraints()) {
      if (conflicts.size() > 0) {
        throw new PropertyResolutionException(this,toplevel(),"String_Node_Str" + toplevel().getFullName() + "String_Node_Str"+ conflicts);
      }
      if (unacceptable.size() > 0) {
        throw new TypeConflictException(unacceptable,"String_Node_Str" + toplevel.getFullName() + "String_Node_Str");
      }
    }
  }
 catch (  IllegalActionException ex) {
    throw new PropertyResolutionException(this,toplevel,ex,"String_Node_Str" + "String_Node_Str");
  }
 finally {
    if (writer != null) {
      try {
        writer.close();
      }
 catch (      IOException ex) {
        throw new PropertyResolutionException(this,toplevel(),ex,"String_Node_Str");
      }
    }
  }
}