Program: 35409
Project: 35409
Buggy source:
/** 
 * This method calculates the alternative path list using the low level Path objects.
 */
public List<Path> calcPaths(GHRequest request,GHResponse ghRsp,ByteArrayBuffer byteBuffer){
  if (ghStorage == null || !fullyLoaded)   throw new IllegalStateException("String_Node_Str");
  if (ghStorage.isClosed())   throw new IllegalStateException("String_Node_Str");
  String vehicle=request.getVehicle();
  if (vehicle.isEmpty()) {
    vehicle=getDefaultVehicle().toString();
    request.setVehicle(vehicle);
  }
  Lock readLock=readWriteLock.readLock();
  readLock.lock();
  try {
    if (!encodingManager.supports(vehicle))     throw new IllegalArgumentException("String_Node_Str" + vehicle + "String_Node_Str"+ "String_Node_Str"+ getEncodingManager());
    HintsMap hints=request.getHints();
    String tModeStr=hints.get("String_Node_Str",traversalMode.toString());
    TraversalMode tMode=TraversalMode.fromString(tModeStr);
    if (hints.has(Routing.EDGE_BASED))     tMode=hints.getBool(Routing.EDGE_BASED,false) ? TraversalMode.EDGE_BASED_2DIR : TraversalMode.NODE_BASED;
    FlagEncoder encoder=encodingManager.getEncoder(vehicle);
    boolean disableCH=hints.getBool(CH.DISABLE,false);
    if (!chFactoryDecorator.isDisablingAllowed() && disableCH)     throw new IllegalArgumentException("String_Node_Str");
    boolean disableLM=hints.getBool(Landmark.DISABLE,false);
    if (!lmFactoryDecorator.isDisablingAllowed() && disableLM)     throw new IllegalArgumentException("String_Node_Str");
    String algoStr=request.getAlgorithm();
    if (algoStr.isEmpty())     algoStr=chFactoryDecorator.isEnabled() && !disableCH && !(lmFactoryDecorator.isEnabled() && !disableLM) ? DIJKSTRA_BI : ASTAR_BI;
    List<GHPoint> points=request.getPoints();
    checkIfPointsAreInBounds(points);
    RoutingTemplate routingTemplate;
    if (ROUND_TRIP.equalsIgnoreCase(algoStr))     routingTemplate=new RoundTripRoutingTemplate(request,ghRsp,locationIndex,maxRoundTripRetries);
 else     if (ALT_ROUTE.equalsIgnoreCase(algoStr))     routingTemplate=new AlternativeRoutingTemplate(request,ghRsp,locationIndex);
 else     routingTemplate=new ViaRoutingTemplate(request,ghRsp,locationIndex);
    List<Path> altPaths=null;
    int maxRetries=routingTemplate.getMaxRetries();
    Locale locale=request.getLocale();
    Translation tr=trMap.getWithFallBack(locale);
    for (int i=0; i < maxRetries; i++) {
      StopWatch sw=new StopWatch().start();
      List<QueryResult> qResults=routingTemplate.lookup(points,encoder,byteBuffer);
      ghRsp.addDebugInfo("String_Node_Str" + sw.stop().getSeconds() + "String_Node_Str");
      if (ghRsp.hasErrors())       return Collections.emptyList();
      RoutingAlgorithmFactory tmpAlgoFactory=getAlgorithmFactory(hints);
      Weighting weighting;
      QueryGraph queryGraph;
      if (chFactoryDecorator.isEnabled() && !disableCH) {
        boolean forceCHHeading=hints.getBool(CH.FORCE_HEADING,false);
        if (!forceCHHeading && request.hasFavoredHeading(0))         throw new IllegalArgumentException("String_Node_Str");
        RoutingAlgorithmFactory chAlgoFactory=tmpAlgoFactory;
        if (tmpAlgoFactory instanceof LMAlgoFactoryDecorator.LMRAFactory)         chAlgoFactory=((LMAlgoFactoryDecorator.LMRAFactory)tmpAlgoFactory).getDefaultAlgoFactory();
        if (chAlgoFactory instanceof PrepareContractionHierarchies)         weighting=((PrepareContractionHierarchies)chAlgoFactory).getWeighting();
 else         throw new IllegalStateException("String_Node_Str" + tmpAlgoFactory);
        tMode=getCHFactoryDecorator().getNodeBase();
        queryGraph=new QueryGraph(ghStorage.getGraph(CHGraph.class,weighting));
        queryGraph.lookup(qResults,byteBuffer);
      }
 else {
        checkNonChMaxWaypointDistance(points);
        queryGraph=new QueryGraph(ghStorage);
        queryGraph.lookup(qResults,byteBuffer);
        weighting=createWeighting(hints,encoder,queryGraph,ghStorage);
        ghRsp.addDebugInfo("String_Node_Str" + tMode.toString());
      }
      int maxVisitedNodesForRequest=hints.getInt(Routing.MAX_VISITED_NODES,maxVisitedNodes);
      if (maxVisitedNodesForRequest > maxVisitedNodes)       throw new IllegalArgumentException("String_Node_Str" + maxVisitedNodes);
      weighting=createTurnWeighting(queryGraph,weighting,tMode);
      AlgorithmOptions algoOpts=AlgorithmOptions.start().algorithm(algoStr).traversalMode(tMode).weighting(weighting).maxVisitedNodes(maxVisitedNodesForRequest).hints(hints).build();
      if (request.getEdgeFilter() != null)       algoOpts.setEdgeFilter(request.getEdgeFilter());
      PathProcessingContext pathProcCntx=new PathProcessingContext(encoder,weighting,tr,request.getEdgeAnnotator(),request.getPathProcessor(),byteBuffer);
      altPaths=routingTemplate.calcPaths(queryGraph,tmpAlgoFactory,algoOpts,pathProcCntx);
      boolean tmpEnableInstructions=hints.getBool(Routing.INSTRUCTIONS,enableInstructions);
      boolean tmpCalcPoints=hints.getBool(Routing.CALC_POINTS,calcPoints);
      double wayPointMaxDistance=hints.getDouble(Routing.WAY_POINT_MAX_DISTANCE,1d);
      DouglasPeucker peucker=new DouglasPeucker().setMaxDistance(wayPointMaxDistance);
      PathMerger pathMerger=new PathMerger().setCalcPoints(tmpCalcPoints).setDouglasPeucker(peucker).setEnableInstructions(tmpEnableInstructions).setSimplifyResponse(simplifyResponse && wayPointMaxDistance > 0);
      if (routingTemplate.isReady(pathMerger,pathProcCntx))       break;
    }
    return altPaths;
  }
 catch (  IllegalArgumentException ex) {
    ghRsp.addError(ex);
    return Collections.emptyList();
  }
 finally {
    readLock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * This method calculates the alternative path list using the low level Path objects.
 */
public List<Path> calcPaths(GHRequest request,GHResponse ghRsp,ByteArrayBuffer byteBuffer){
  if (ghStorage == null || !fullyLoaded)   throw new IllegalStateException("String_Node_Str");
  if (ghStorage.isClosed())   throw new IllegalStateException("String_Node_Str");
  String vehicle=request.getVehicle();
  if (vehicle.isEmpty()) {
    vehicle=getDefaultVehicle().toString();
    request.setVehicle(vehicle);
  }
  Lock readLock=readWriteLock.readLock();
  readLock.lock();
  try {
    if (!encodingManager.supports(vehicle))     throw new IllegalArgumentException("String_Node_Str" + vehicle + "String_Node_Str"+ "String_Node_Str"+ getEncodingManager());
    HintsMap hints=request.getHints();
    String tModeStr=hints.get("String_Node_Str",traversalMode.toString());
    TraversalMode tMode=TraversalMode.fromString(tModeStr);
    if (hints.has(Routing.EDGE_BASED))     tMode=hints.getBool(Routing.EDGE_BASED,false) ? TraversalMode.EDGE_BASED_2DIR : TraversalMode.NODE_BASED;
    FlagEncoder encoder=encodingManager.getEncoder(vehicle);
    boolean disableCH=hints.getBool(CH.DISABLE,false);
    if (!chFactoryDecorator.isDisablingAllowed() && disableCH)     throw new IllegalArgumentException("String_Node_Str");
    boolean disableLM=hints.getBool(Landmark.DISABLE,false);
    if (!lmFactoryDecorator.isDisablingAllowed() && disableLM)     throw new IllegalArgumentException("String_Node_Str");
    String algoStr=request.getAlgorithm();
    if (algoStr.isEmpty())     algoStr=chFactoryDecorator.isEnabled() && !disableCH && !(lmFactoryDecorator.isEnabled() && !disableLM) ? DIJKSTRA_BI : ASTAR_BI;
    List<GHPoint> points=request.getPoints();
    checkIfPointsAreInBounds(points);
    RoutingTemplate routingTemplate;
    if (ROUND_TRIP.equalsIgnoreCase(algoStr))     routingTemplate=new RoundTripRoutingTemplate(request,ghRsp,locationIndex,maxRoundTripRetries);
 else     if (ALT_ROUTE.equalsIgnoreCase(algoStr))     routingTemplate=new AlternativeRoutingTemplate(request,ghRsp,locationIndex);
 else     routingTemplate=new ViaRoutingTemplate(request,ghRsp,locationIndex);
    List<Path> altPaths=null;
    int maxRetries=routingTemplate.getMaxRetries();
    Locale locale=request.getLocale();
    Translation tr=trMap.getWithFallBack(locale);
    for (int i=0; i < maxRetries; i++) {
      StopWatch sw=new StopWatch().start();
      List<QueryResult> qResults=routingTemplate.lookup(points,encoder,byteBuffer);
      ghRsp.addDebugInfo("String_Node_Str" + sw.stop().getSeconds() + "String_Node_Str");
      if (ghRsp.hasErrors())       return Collections.emptyList();
      RoutingAlgorithmFactory tmpAlgoFactory=getAlgorithmFactory(hints);
      Weighting weighting;
      QueryGraph queryGraph;
      if (chFactoryDecorator.isEnabled() && !disableCH) {
        boolean forceCHHeading=hints.getBool(CH.FORCE_HEADING,false);
        if (!forceCHHeading && request.hasFavoredHeading(0))         throw new IllegalArgumentException("String_Node_Str");
        RoutingAlgorithmFactory chAlgoFactory=tmpAlgoFactory;
        if (tmpAlgoFactory instanceof LMAlgoFactoryDecorator.LMRAFactory)         chAlgoFactory=((LMAlgoFactoryDecorator.LMRAFactory)tmpAlgoFactory).getDefaultAlgoFactory();
        if (chAlgoFactory instanceof PrepareContractionHierarchies)         weighting=((PrepareContractionHierarchies)chAlgoFactory).getWeighting();
 else         throw new IllegalStateException("String_Node_Str" + tmpAlgoFactory);
        tMode=getCHFactoryDecorator().getNodeBase();
        queryGraph=new QueryGraph(ghStorage.getGraph(CHGraph.class,weighting));
        queryGraph.lookup(qResults,byteBuffer);
      }
 else {
        checkNonChMaxWaypointDistance(points);
        queryGraph=new QueryGraph(ghStorage);
        queryGraph.lookup(qResults,byteBuffer);
        weighting=createWeighting(hints,tMode,encoder,queryGraph,ghStorage);
        ghRsp.addDebugInfo("String_Node_Str" + tMode.toString());
      }
      int maxVisitedNodesForRequest=hints.getInt(Routing.MAX_VISITED_NODES,maxVisitedNodes);
      if (maxVisitedNodesForRequest > maxVisitedNodes)       throw new IllegalArgumentException("String_Node_Str" + maxVisitedNodes);
      AlgorithmOptions algoOpts=AlgorithmOptions.start().algorithm(algoStr).traversalMode(tMode).weighting(weighting).maxVisitedNodes(maxVisitedNodesForRequest).hints(hints).build();
      if (request.getEdgeFilter() != null)       algoOpts.setEdgeFilter(request.getEdgeFilter());
      PathProcessingContext pathProcCntx=new PathProcessingContext(encoder,weighting,tr,request.getEdgeAnnotator(),request.getPathProcessor(),byteBuffer);
      altPaths=routingTemplate.calcPaths(queryGraph,tmpAlgoFactory,algoOpts,pathProcCntx);
      boolean tmpEnableInstructions=hints.getBool(Routing.INSTRUCTIONS,enableInstructions);
      boolean tmpCalcPoints=hints.getBool(Routing.CALC_POINTS,calcPoints);
      double wayPointMaxDistance=hints.getDouble(Routing.WAY_POINT_MAX_DISTANCE,1d);
      DouglasPeucker peucker=new DouglasPeucker().setMaxDistance(wayPointMaxDistance);
      PathMerger pathMerger=new PathMerger().setCalcPoints(tmpCalcPoints).setDouglasPeucker(peucker).setEnableInstructions(tmpEnableInstructions).setSimplifyResponse(simplifyResponse && wayPointMaxDistance > 0);
      if (routingTemplate.isReady(pathMerger,pathProcCntx))       break;
    }
    return altPaths;
  }
 catch (  IllegalArgumentException ex) {
    ghRsp.addError(ex);
    return Collections.emptyList();
  }
 finally {
    readLock.unlock();
  }
}