Program: 35397
Project: 35397
Buggy source:
private RouteSearchContext createSearchContext(RouteSearchParameters searchParams,RouteSearchMode mode,EdgeFilter customEdgeFilter) throws Exception {
  int profileType=searchParams.getProfileType();
  int weightingMethod=searchParams.getWeightingMethod();
  String encoderName=RoutingProfileType.getEncoderName(profileType);
  EdgeFilter edgeFilter=null;
  FlagEncoder flagEncoder=mGraphHopper.getEncodingManager().getEncoder(encoderName);
  PMap props=new PMap();
  if (searchParams.hasAvoidAreas()) {
    if (encoderName.isEmpty())     throw new InternalServerException(RoutingErrorCodes.UNKNOWN,"String_Node_Str");
    if (!mGraphHopper.getEncodingManager().supports(encoderName)) {
      throw new IllegalArgumentException("String_Node_Str" + encoderName + "String_Node_Str"+ "String_Node_Str"+ mGraphHopper.getEncodingManager());
    }
    edgeFilter=new AvoidAreasEdgeFilter(flagEncoder,searchParams.getAvoidAreas());
  }
  if (RoutingProfileType.isDriving(profileType)) {
    if (RoutingProfileType.isHeavyVehicle(profileType)) {
      edgeFilter=createHeavyVehicleEdgeFilter(searchParams,flagEncoder,edgeFilter);
    }
 else     if (searchParams.hasParameters(VehicleParameters.class)) {
    }
  }
 else   if (profileType == RoutingProfileType.WHEELCHAIR) {
    if (searchParams.hasParameters(WheelchairParameters.class)) {
      edgeFilter=createWheelchairRestrictionsEdgeFilter(searchParams,flagEncoder,edgeFilter);
    }
  }
  if (searchParams.hasAvoidFeatures()) {
    if (RoutingProfileType.isDriving(profileType) || RoutingProfileType.isCycling(profileType) || profileType == RoutingProfileType.FOOT_WALKING || profileType == RoutingProfileType.FOOT_HIKING || profileType == RoutingProfileType.WHEELCHAIR) {
      if (searchParams.getAvoidFeatureTypes() != AvoidFeatureFlags.Hills && searchParams.getAvoidFeatureTypes() != AvoidFeatureFlags.Borders && searchParams.getAvoidFeatureTypes() != AvoidFeatureFlags.ControlledBorders) {
        EdgeFilter ef=new AvoidFeaturesEdgeFilter(flagEncoder,searchParams,mGraphHopper.getGraphHopperStorage());
        edgeFilter=createEdgeFilter(ef,edgeFilter);
      }
      if (mode == RouteSearchMode.Routing) {
        if ((searchParams.getAvoidFeatureTypes() & AvoidFeatureFlags.Hills) == AvoidFeatureFlags.Hills) {
          props.put("String_Node_Str",true);
          props.put(ProfileWeighting.encodeName("String_Node_Str"),true);
          if (searchParams.hasParameters(CyclingParameters.class)) {
            CyclingParameters cyclingParams=(CyclingParameters)searchParams.getProfileParameters();
            props.put("String_Node_Str",cyclingParams.getMaximumGradient());
          }
        }
        if ((searchParams.getAvoidFeatureTypes() & AvoidFeatureFlags.Borders) == AvoidFeatureFlags.Borders) {
          props.put("String_Node_Str",true);
          props.put(ProfileWeighting.encodeName("String_Node_Str") + "String_Node_Str",1);
        }
        if ((searchParams.getAvoidFeatureTypes() & AvoidFeatureFlags.ControlledBorders) == AvoidFeatureFlags.ControlledBorders) {
          props.put("String_Node_Str",true);
          props.put(ProfileWeighting.encodeName("String_Node_Str") + "String_Node_Str",2);
        }
      }
    }
  }
  if (searchParams.hasParameters(CyclingParameters.class)) {
    CyclingParameters cyclingParams=(CyclingParameters)searchParams.getProfileParameters();
    if (cyclingParams.getMaximumGradient() > 0) {
      EdgeFilter ef=new AvoidSteepnessEdgeFilter(flagEncoder,mGraphHopper.getGraphHopperStorage(),cyclingParams.getMaximumGradient());
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
    if (cyclingParams.getMaximumTrailDifficulty() > 0) {
      EdgeFilter ef=new TrailDifficultyEdgeFilter(flagEncoder,mGraphHopper.getGraphHopperStorage(),cyclingParams.getMaximumTrailDifficulty());
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
  }
 else   if (searchParams.hasParameters(WalkingParameters.class)) {
    WalkingParameters walkingParams=(WalkingParameters)searchParams.getProfileParameters();
    if (walkingParams.getMaximumGradient() > 0) {
      EdgeFilter ef=new AvoidSteepnessEdgeFilter(flagEncoder,mGraphHopper.getGraphHopperStorage(),walkingParams.getMaximumGradient());
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
    if (walkingParams.getMaximumTrailDifficulty() > 0) {
      EdgeFilter ef=new TrailDifficultyEdgeFilter(flagEncoder,mGraphHopper.getGraphHopperStorage(),walkingParams.getMaximumTrailDifficulty());
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
  }
  ProfileParameters profileParams=searchParams.getProfileParameters();
  if (profileParams != null && profileParams.hasWeightings()) {
    props.put("String_Node_Str",true);
    Iterator<ProfileWeighting> iterator=profileParams.getWeightings().getIterator();
    while (iterator.hasNext()) {
      ProfileWeighting weighting=iterator.next();
      if (!weighting.getParameters().isEmpty()) {
        String name=ProfileWeighting.encodeName(weighting.getName());
        for (        Map.Entry<String,String> kv : weighting.getParameters().getMap().entrySet())         props.put(name + kv.getKey(),kv.getValue());
      }
    }
  }
  if (searchParams.getConsiderTraffic()) {
    if (RoutingProfileType.isDriving(profileType) && weightingMethod != WeightingMethod.SHORTEST && RealTrafficDataProvider.getInstance().isInitialized()) {
      props.put("String_Node_Str",true);
      EdgeFilter ef=new BlockedEdgesEdgeFilter(flagEncoder,RealTrafficDataProvider.getInstance().getBlockedEdges(mGraphHopper.getGraphHopperStorage()),RealTrafficDataProvider.getInstance().getHeavyVehicleBlockedEdges(mGraphHopper.getGraphHopperStorage()));
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
  }
  if (edgeFilter == null)   edgeFilter=new DefaultEdgeFilter(flagEncoder);
  RouteSearchContext searchCntx=new RouteSearchContext(mGraphHopper,edgeFilter,flagEncoder);
  searchCntx.setProperties(props);
  return searchCntx;
}

Fixed version (ground truth):
private RouteSearchContext createSearchContext(RouteSearchParameters searchParams,RouteSearchMode mode,EdgeFilter customEdgeFilter) throws Exception {
  int profileType=searchParams.getProfileType();
  int weightingMethod=searchParams.getWeightingMethod();
  String encoderName=RoutingProfileType.getEncoderName(profileType);
  EdgeFilter edgeFilter=null;
  FlagEncoder flagEncoder=mGraphHopper.getEncodingManager().getEncoder(encoderName);
  PMap props=new PMap();
  if (searchParams.hasAvoidAreas()) {
    if (encoderName.isEmpty())     throw new InternalServerException(RoutingErrorCodes.UNKNOWN,"String_Node_Str");
    if (!mGraphHopper.getEncodingManager().supports(encoderName)) {
      throw new IllegalArgumentException("String_Node_Str" + encoderName + "String_Node_Str"+ "String_Node_Str"+ mGraphHopper.getEncodingManager());
    }
    edgeFilter=new AvoidAreasEdgeFilter(flagEncoder,searchParams.getAvoidAreas());
  }
  if (RoutingProfileType.isDriving(profileType)) {
    if (RoutingProfileType.isHeavyVehicle(profileType)) {
      edgeFilter=createHeavyVehicleEdgeFilter(searchParams,flagEncoder,edgeFilter);
    }
 else     if (searchParams.hasParameters(VehicleParameters.class)) {
    }
  }
 else   if (profileType == RoutingProfileType.WHEELCHAIR) {
    if (searchParams.hasParameters(WheelchairParameters.class)) {
      edgeFilter=createWheelchairRestrictionsEdgeFilter(searchParams,flagEncoder,edgeFilter);
    }
  }
  if (searchParams.hasAvoidFeatures()) {
    if (RoutingProfileType.isDriving(profileType) || RoutingProfileType.isCycling(profileType) || profileType == RoutingProfileType.FOOT_WALKING || profileType == RoutingProfileType.FOOT_HIKING || profileType == RoutingProfileType.WHEELCHAIR) {
      if (searchParams.getAvoidFeatureTypes() != AvoidFeatureFlags.Hills && searchParams.getAvoidFeatureTypes() != AvoidFeatureFlags.Borders && searchParams.getAvoidFeatureTypes() != AvoidFeatureFlags.ControlledBorders) {
        EdgeFilter ef=new AvoidFeaturesEdgeFilter(flagEncoder,searchParams,mGraphHopper.getGraphHopperStorage());
        edgeFilter=createEdgeFilter(ef,edgeFilter);
      }
      if (mode == RouteSearchMode.Routing) {
        if ((searchParams.getAvoidFeatureTypes() & AvoidFeatureFlags.Hills) == AvoidFeatureFlags.Hills) {
          props.put("String_Node_Str",true);
          props.put(ProfileWeighting.encodeName("String_Node_Str"),true);
          if (searchParams.hasParameters(CyclingParameters.class)) {
            CyclingParameters cyclingParams=(CyclingParameters)searchParams.getProfileParameters();
            props.put("String_Node_Str",cyclingParams.getMaximumGradient());
          }
        }
      }
    }
  }
  if (searchParams.hasParameters(CyclingParameters.class)) {
    CyclingParameters cyclingParams=(CyclingParameters)searchParams.getProfileParameters();
    if (cyclingParams.getMaximumGradient() > 0) {
      EdgeFilter ef=new AvoidSteepnessEdgeFilter(flagEncoder,mGraphHopper.getGraphHopperStorage(),cyclingParams.getMaximumGradient());
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
    if (cyclingParams.getMaximumTrailDifficulty() > 0) {
      EdgeFilter ef=new TrailDifficultyEdgeFilter(flagEncoder,mGraphHopper.getGraphHopperStorage(),cyclingParams.getMaximumTrailDifficulty());
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
  }
 else   if (searchParams.hasParameters(WalkingParameters.class)) {
    WalkingParameters walkingParams=(WalkingParameters)searchParams.getProfileParameters();
    if (walkingParams.getMaximumGradient() > 0) {
      EdgeFilter ef=new AvoidSteepnessEdgeFilter(flagEncoder,mGraphHopper.getGraphHopperStorage(),walkingParams.getMaximumGradient());
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
    if (walkingParams.getMaximumTrailDifficulty() > 0) {
      EdgeFilter ef=new TrailDifficultyEdgeFilter(flagEncoder,mGraphHopper.getGraphHopperStorage(),walkingParams.getMaximumTrailDifficulty());
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
  }
  ProfileParameters profileParams=searchParams.getProfileParameters();
  if (profileParams != null && profileParams.hasWeightings()) {
    props.put("String_Node_Str",true);
    Iterator<ProfileWeighting> iterator=profileParams.getWeightings().getIterator();
    while (iterator.hasNext()) {
      ProfileWeighting weighting=iterator.next();
      if (!weighting.getParameters().isEmpty()) {
        String name=ProfileWeighting.encodeName(weighting.getName());
        for (        Map.Entry<String,String> kv : weighting.getParameters().getMap().entrySet())         props.put(name + kv.getKey(),kv.getValue());
      }
    }
  }
  if (searchParams.getConsiderTraffic()) {
    if (RoutingProfileType.isDriving(profileType) && weightingMethod != WeightingMethod.SHORTEST && RealTrafficDataProvider.getInstance().isInitialized()) {
      props.put("String_Node_Str",true);
      EdgeFilter ef=new BlockedEdgesEdgeFilter(flagEncoder,RealTrafficDataProvider.getInstance().getBlockedEdges(mGraphHopper.getGraphHopperStorage()),RealTrafficDataProvider.getInstance().getHeavyVehicleBlockedEdges(mGraphHopper.getGraphHopperStorage()));
      edgeFilter=createEdgeFilter(ef,edgeFilter);
    }
  }
  if (edgeFilter == null)   edgeFilter=new DefaultEdgeFilter(flagEncoder);
  RouteSearchContext searchCntx=new RouteSearchContext(mGraphHopper,edgeFilter,flagEncoder);
  searchCntx.setProperties(props);
  return searchCntx;
}