Program: 35401
Project: 35401
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,featName))             throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str",featName);
            flags|=flag;
          }
        }
        if (flags != 0)         _avoidFeaturesTypes=flags;
      }
    }
  }
  if (json.has("String_Node_Str")) {
    JSONObject jProfileParams=json.getJSONObject("String_Node_Str");
    JSONObject jRestrictions=null;
    if (jProfileParams.has("String_Node_Str"))     jRestrictions=jProfileParams.getJSONObject("String_Node_Str");
    if (RoutingProfileType.isDriving(_profileType)) {
      VehicleParameters vehicleParams=new VehicleParameters();
      _profileParams=vehicleParams;
    }
 else     if (RoutingProfileType.isCycling(_profileType)) {
      CyclingParameters cyclingParams=new CyclingParameters();
      if (jRestrictions != null) {
        if (jRestrictions.has("String_Node_Str"))         cyclingParams.setMaximumGradient(jRestrictions.getInt("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         cyclingParams.setMaximumTrailDifficulty(jRestrictions.getInt("String_Node_Str"));
      }
      _profileParams=cyclingParams;
    }
 else     if (RoutingProfileType.isWalking(_profileType)) {
      WalkingParameters walkingParams=new WalkingParameters();
      if (jRestrictions != null) {
        if (jRestrictions.has("String_Node_Str"))         walkingParams.setMaximumGradient(jRestrictions.getInt("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         walkingParams.setMaximumTrailDifficulty(jRestrictions.getInt("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);
        if (jRestrictions == null)         jRestrictions=jProfileParams;
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setLength(jRestrictions.getDouble("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setWidth(jRestrictions.getDouble("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setHeight(jRestrictions.getDouble("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setWeight(jRestrictions.getDouble("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setAxleload(jRestrictions.getDouble("String_Node_Str"));
        int loadCharacteristics=0;
        if (jRestrictions.has("String_Node_Str") && jRestrictions.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();
      if (jRestrictions == null)       jRestrictions=jProfileParams;
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setSurfaceType(WheelchairTypesEncoder.getSurfaceType(jRestrictions.getString("String_Node_Str")));
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setTrackType(WheelchairTypesEncoder.getTrackType(jRestrictions.getString("String_Node_Str")));
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setSmoothnessType(WheelchairTypesEncoder.getSmoothnessType(jRestrictions.getString("String_Node_Str")));
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setMaximumSlopedCurb((float)jRestrictions.getDouble("String_Node_Str"));
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setMaximumIncline((float)jRestrictions.getDouble("String_Node_Str"));
      _profileParams=wheelchairParams;
    }
    processWeightings(jProfileParams,_profileParams);
  }
  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");
    }
  }
}

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,featName))             throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str",featName);
            flags|=flag;
          }
        }
        if (flags != 0)         _avoidFeaturesTypes=flags;
      }
    }
  }
  if (json.has("String_Node_Str")) {
    JSONObject jProfileParams=json.getJSONObject("String_Node_Str");
    JSONObject jRestrictions=null;
    if (jProfileParams.has("String_Node_Str"))     jRestrictions=jProfileParams.getJSONObject("String_Node_Str");
    if (RoutingProfileType.isDriving(_profileType)) {
      VehicleParameters vehicleParams=new VehicleParameters();
      _profileParams=vehicleParams;
    }
    if (RoutingProfileType.isCycling(_profileType)) {
      CyclingParameters cyclingParams=new CyclingParameters();
      if (jRestrictions != null) {
        if (jRestrictions.has("String_Node_Str"))         cyclingParams.setMaximumGradient(jRestrictions.getInt("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         cyclingParams.setMaximumTrailDifficulty(jRestrictions.getInt("String_Node_Str"));
      }
      _profileParams=cyclingParams;
    }
 else     if (RoutingProfileType.isWalking(_profileType)) {
      WalkingParameters walkingParams=new WalkingParameters();
      if (jRestrictions != null) {
        if (jRestrictions.has("String_Node_Str"))         walkingParams.setMaximumGradient(jRestrictions.getInt("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         walkingParams.setMaximumTrailDifficulty(jRestrictions.getInt("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);
        if (jRestrictions == null)         jRestrictions=jProfileParams;
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setLength(jRestrictions.getDouble("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setWidth(jRestrictions.getDouble("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setHeight(jRestrictions.getDouble("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setWeight(jRestrictions.getDouble("String_Node_Str"));
        if (jRestrictions.has("String_Node_Str"))         vehicleParams.setAxleload(jRestrictions.getDouble("String_Node_Str"));
        int loadCharacteristics=0;
        if (jRestrictions.has("String_Node_Str") && jRestrictions.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();
      if (jRestrictions == null)       jRestrictions=jProfileParams;
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setSurfaceType(WheelchairTypesEncoder.getSurfaceType(jRestrictions.getString("String_Node_Str")));
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setTrackType(WheelchairTypesEncoder.getTrackType(jRestrictions.getString("String_Node_Str")));
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setSmoothnessType(WheelchairTypesEncoder.getSmoothnessType(jRestrictions.getString("String_Node_Str")));
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setMaximumSlopedCurb((float)jRestrictions.getDouble("String_Node_Str"));
      if (jRestrictions.has("String_Node_Str"))       wheelchairParams.setMaximumIncline((float)jRestrictions.getDouble("String_Node_Str"));
      _profileParams=wheelchairParams;
    }
    processWeightings(jProfileParams,_profileParams);
  }
  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");
    }
  }
}