Program: 35431
Project: 35431
Buggy source:
public void setOptions(String options) throws Exception {
  if (options == null)   return;
  _options=StringUtility.trim(options,'\"');
  JSONObject json=null;
  try {
    json=new JSONObject(_options);
  }
 catch (  Exception ex) {
    throw new ParseException(ex.getMessage(),0);
  }
  if (json.has("String_Node_Str")) {
    try {
      _maxSpeed=json.getDouble("String_Node_Str");
    }
 catch (    Exception ex) {
      throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_FORMAT,"String_Node_Str",json.getString("String_Node_Str"));
    }
  }
  if (json.has("String_Node_Str")) {
    String keyValue=json.getString("String_Node_Str");
    if (!Helper.isEmpty(keyValue)) {
      String[] avoidFeatures=keyValue.split("String_Node_Str");
      if (avoidFeatures != null && avoidFeatures.length > 0) {
        int flags=0;
        for (int i=0; i < avoidFeatures.length; i++) {
          String featName=avoidFeatures[i];
          if (featName != null) {
            int flag=AvoidFeatureFlags.getFromString(featName);
            if (flag == 0)             throw new UnknownParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str",featName);
            if (!AvoidFeatureFlags.isValid(_profileType,flag))             throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str",featName);
            flags|=flag;
          }
        }
        if (flags != 0)         _avoidFeaturesTypes=flags;
      }
    }
  }
  if (json.has("String_Node_Str")) {
    if (RoutingProfileType.isCycling(_profileType)) {
      CyclingParameters cyclingParams=new CyclingParameters();
      JSONObject jFitnessParams=json.getJSONObject("String_Node_Str");
      if (jFitnessParams.has("String_Node_Str"))       cyclingParams.setDifficultyLevel(jFitnessParams.getInt("String_Node_Str"));
      if (jFitnessParams.has("String_Node_Str"))       cyclingParams.setMaximumGradient(jFitnessParams.getInt("String_Node_Str"));
      _profileParams=cyclingParams;
    }
 else     if (RoutingProfileType.isWalking(_profileType)) {
      WalkingParameters walkingParams=new WalkingParameters();
      JSONObject walkingProfileParams=json.getJSONObject("String_Node_Str");
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setGreenRouting(walkingProfileParams.getBoolean("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setQuietRouting(walkingProfileParams.getBoolean("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setDifficultyLevel(walkingProfileParams.getInt("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setMaximumGradient(walkingProfileParams.getInt("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setGreenWeightingFactor(walkingProfileParams.getDouble("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setQuietWeightingFactor(walkingProfileParams.getDouble("String_Node_Str"));
      _profileParams=walkingParams;
    }
 else     if (RoutingProfileType.isHeavyVehicle(_profileType) == true) {
      VehicleParameters vehicleParams=new VehicleParameters();
      if (json.has("String_Node_Str")) {
        String vehicleType=json.getString("String_Node_Str");
        _vehicleType=HeavyVehicleAttributes.getFromString(vehicleType);
        JSONObject jVehicleParams=json.getJSONObject("String_Node_Str");
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setLength(jVehicleParams.getDouble("String_Node_Str"));
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setWidth(jVehicleParams.getDouble("String_Node_Str"));
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setHeight(jVehicleParams.getDouble("String_Node_Str"));
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setWeight(jVehicleParams.getDouble("String_Node_Str"));
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setAxleload(jVehicleParams.getDouble("String_Node_Str"));
        int loadCharacteristics=0;
        if (jVehicleParams.has("String_Node_Str") && jVehicleParams.getBoolean("String_Node_Str") == true)         loadCharacteristics|=VehicleLoadCharacteristicsFlags.HAZMAT;
        if (loadCharacteristics != 0)         vehicleParams.setLoadCharacteristics(loadCharacteristics);
      }
      _profileParams=vehicleParams;
    }
 else     if (_profileType == RoutingProfileType.WHEELCHAIR) {
      WheelchairParameters wheelchairParams=new WheelchairParameters();
      JSONObject jWheelchairParams=json.getJSONObject("String_Node_Str");
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setSurfaceType(WheelchairTypesEncoder.getSurfaceType(jWheelchairParams.getString("String_Node_Str")));
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setTrackType(WheelchairTypesEncoder.getTrackType(jWheelchairParams.getString("String_Node_Str")));
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setSmoothnessType(WheelchairTypesEncoder.getSmoothnessType(jWheelchairParams.getString("String_Node_Str")));
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setMaximumSlopedCurb((float)jWheelchairParams.getDouble("String_Node_Str"));
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setMaximumIncline((float)jWheelchairParams.getDouble("String_Node_Str"));
      _profileParams=wheelchairParams;
    }
  }
  if (json.has("String_Node_Str")) {
    JSONObject jFeature=(JSONObject)json.get("String_Node_Str");
    Geometry geom=null;
    try {
      geom=GeometryJSON.parse(jFeature);
    }
 catch (    Exception ex) {
      throw new ParameterValueException(RoutingErrorCodes.INVALID_JSON_FORMAT,"String_Node_Str");
    }
    if (geom instanceof Polygon) {
      _avoidAreas=new Polygon[]{(Polygon)geom};
    }
 else     if (geom instanceof MultiPolygon) {
      MultiPolygon multiPoly=(MultiPolygon)geom;
      _avoidAreas=new Polygon[multiPoly.getNumGeometries()];
      for (int i=0; i < multiPoly.getNumGeometries(); i++)       _avoidAreas[i]=(Polygon)multiPoly.getGeometryN(i);
    }
 else {
      throw new Exception("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void setOptions(String options) throws Exception {
  if (options == null)   return;
  _options=StringUtility.trim(options,'\"');
  JSONObject json=null;
  try {
    json=new JSONObject(_options);
  }
 catch (  Exception ex) {
    throw new ParseException(ex.getMessage(),0);
  }
  if (json.has("String_Node_Str")) {
    try {
      _maxSpeed=json.getDouble("String_Node_Str");
    }
 catch (    Exception ex) {
      throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_FORMAT,"String_Node_Str",json.getString("String_Node_Str"));
    }
  }
  if (json.has("String_Node_Str")) {
    String keyValue=json.getString("String_Node_Str");
    if (!Helper.isEmpty(keyValue)) {
      String[] avoidFeatures=keyValue.split("String_Node_Str");
      if (avoidFeatures != null && avoidFeatures.length > 0) {
        int flags=0;
        for (int i=0; i < avoidFeatures.length; i++) {
          String featName=avoidFeatures[i];
          if (featName != null) {
            int flag=AvoidFeatureFlags.getFromString(featName);
            if (flag == 0)             throw new UnknownParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str",featName);
            if (!AvoidFeatureFlags.isValid(_profileType,flag))             throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str",featName);
            flags|=flag;
          }
        }
        if (flags != 0)         _avoidFeaturesTypes=flags;
      }
    }
  }
  if (json.has("String_Node_Str")) {
    if (RoutingProfileType.isCycling(_profileType)) {
      CyclingParameters cyclingParams=new CyclingParameters();
      JSONObject jFitnessParams=json.getJSONObject("String_Node_Str");
      if (jFitnessParams.has("String_Node_Str"))       cyclingParams.setDifficultyLevel(jFitnessParams.getInt("String_Node_Str"));
      if (jFitnessParams.has("String_Node_Str"))       cyclingParams.setMaximumGradient(jFitnessParams.getInt("String_Node_Str"));
      _profileParams=cyclingParams;
    }
 else     if (RoutingProfileType.isWalking(_profileType)) {
      WalkingParameters walkingParams=new WalkingParameters();
      JSONObject walkingProfileParams=json.getJSONObject("String_Node_Str");
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setGreenRouting(walkingProfileParams.getBoolean("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setQuietRouting(walkingProfileParams.getBoolean("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setDifficultyLevel(walkingProfileParams.getInt("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setMaximumGradient(walkingProfileParams.getInt("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setGreenWeightingFactor(walkingProfileParams.getDouble("String_Node_Str"));
      if (walkingProfileParams.has("String_Node_Str"))       walkingParams.setQuietWeightingFactor(walkingProfileParams.getDouble("String_Node_Str"));
      _profileParams=walkingParams;
    }
 else     if (RoutingProfileType.isHeavyVehicle(_profileType) == true) {
      VehicleParameters vehicleParams=new VehicleParameters();
      if (json.has("String_Node_Str")) {
        String vehicleType=json.getString("String_Node_Str");
        _vehicleType=HeavyVehicleAttributes.getFromString(vehicleType);
        JSONObject jVehicleParams=json.getJSONObject("String_Node_Str");
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setLength(jVehicleParams.getDouble("String_Node_Str"));
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setWidth(jVehicleParams.getDouble("String_Node_Str"));
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setHeight(jVehicleParams.getDouble("String_Node_Str"));
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setWeight(jVehicleParams.getDouble("String_Node_Str"));
        if (jVehicleParams.has("String_Node_Str"))         vehicleParams.setAxleload(jVehicleParams.getDouble("String_Node_Str"));
        int loadCharacteristics=0;
        if (jVehicleParams.has("String_Node_Str") && jVehicleParams.getBoolean("String_Node_Str") == true)         loadCharacteristics|=VehicleLoadCharacteristicsFlags.HAZMAT;
        if (loadCharacteristics != 0)         vehicleParams.setLoadCharacteristics(loadCharacteristics);
      }
      _profileParams=vehicleParams;
    }
 else     if (_profileType == RoutingProfileType.WHEELCHAIR) {
      WheelchairParameters wheelchairParams=new WheelchairParameters();
      JSONObject jWheelchairParams=json.getJSONObject("String_Node_Str");
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setSurfaceType(WheelchairTypesEncoder.getSurfaceType(jWheelchairParams.getString("String_Node_Str")));
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setTrackType(WheelchairTypesEncoder.getTrackType(jWheelchairParams.getString("String_Node_Str")));
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setSmoothnessType(WheelchairTypesEncoder.getSmoothnessType(jWheelchairParams.getString("String_Node_Str")));
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setMaximumSlopedCurb((float)jWheelchairParams.getDouble("String_Node_Str"));
      if (jWheelchairParams.has("String_Node_Str"))       wheelchairParams.setMaximumIncline((float)jWheelchairParams.getDouble("String_Node_Str"));
      _profileParams=wheelchairParams;
    }
  }
  if (json.has("String_Node_Str")) {
    JSONObject jFeature=(JSONObject)json.get("String_Node_Str");
    Geometry geom=null;
    try {
      geom=GeometryJSON.parse(jFeature);
    }
 catch (    Exception ex) {
      throw new ParameterValueException(RoutingErrorCodes.INVALID_JSON_FORMAT,"String_Node_Str");
    }
    if (geom instanceof Polygon) {
      _avoidAreas=new Polygon[]{(Polygon)geom};
    }
 else     if (geom instanceof MultiPolygon) {
      MultiPolygon multiPoly=(MultiPolygon)geom;
      _avoidAreas=new Polygon[multiPoly.getNumGeometries()];
      for (int i=0; i < multiPoly.getNumGeometries(); i++)       _avoidAreas[i]=(Polygon)multiPoly.getGeometryN(i);
    }
 else {
      throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str");
    }
  }
}