Program: 33320
Project: 33320
Buggy source:
public UriInfo parseUri(final String input,final Edm edm) throws UriParserException {
  boolean readQueryParameter=false;
  boolean readFragment=false;
  UriContext context=new UriContext();
  UriParseTreeVisitor uriParseTreeVisitor=new UriParseTreeVisitor(edm,context);
  try {
    RawUri uri=UriDecoder.decodeUri(input,0);
    String firstSegment="String_Node_Str";
    if (uri.pathSegmentListDecoded.size() > 0) {
      firstSegment=uri.pathSegmentListDecoded.get(0);
    }
    if (firstSegment.length() == 0) {
      readQueryParameter=true;
      context.contextUriInfo=new UriInfoImpl().setKind(UriInfoKind.service);
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      BatchEOFContext ctxBatchEOF=(BatchEOFContext)parseRule(uri.pathSegmentListDecoded.get(0),ParserEntryRules.Batch);
      uriParseTreeVisitor.visitBatchEOF(ctxBatchEOF);
      readQueryParameter=true;
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      MetadataEOFContext ctxMetadataEOF=(MetadataEOFContext)parseRule(uri.pathSegmentListDecoded.get(0),ParserEntryRules.Metadata);
      uriParseTreeVisitor.visitMetadataEOF(ctxMetadataEOF);
      readQueryParameter=true;
      readFragment=true;
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      context.contextUriInfo=new UriInfoImpl().setKind(UriInfoKind.entityId);
      if (uri.pathSegmentListDecoded.size() > 1) {
        EntityEOFContext ctxEntityEOF=(EntityEOFContext)parseRule(uri.pathSegmentListDecoded.get(1),ParserEntryRules.Entity);
        uriParseTreeVisitor.visitEntityEOF(ctxEntityEOF);
      }
      readQueryParameter=true;
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      AllEOFContext ctxResourcePathEOF=(AllEOFContext)parseRule(uri.pathSegmentListDecoded.get(0),ParserEntryRules.All);
      uriParseTreeVisitor.visitAllEOF(ctxResourcePathEOF);
      readQueryParameter=true;
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      CrossjoinEOFContext ctxResourcePathEOF=(CrossjoinEOFContext)parseRule(uri.pathSegmentListDecoded.get(0),ParserEntryRules.CrossJoin);
      uriParseTreeVisitor.visitCrossjoinEOF(ctxResourcePathEOF);
      readQueryParameter=true;
    }
 else {
      List<PathSegmentEOFContext> ctxPathSegments=new ArrayList<PathSegmentEOFContext>();
      for (      String pathSegment : uri.pathSegmentListDecoded) {
        PathSegmentEOFContext ctxPathSegment=(PathSegmentEOFContext)parseRule(pathSegment,ParserEntryRules.PathSegment);
        ctxPathSegments.add(ctxPathSegment);
      }
      context.contextUriInfo=new UriInfoImpl().setKind(UriInfoKind.resource);
      for (      PathSegmentEOFContext ctxPathSegment : ctxPathSegments) {
        uriParseTreeVisitor.visitPathSegmentEOF(ctxPathSegment);
      }
      UriResource lastSegment=context.contextUriInfo.getLastResourcePart();
      if (lastSegment instanceof UriResourcePartTyped) {
        UriResourcePartTyped typed=(UriResourcePartTyped)lastSegment;
        UriParseTreeVisitor.TypeInformation myType=uriParseTreeVisitor.getTypeInformation(typed);
        UriParseTreeVisitor.TypeInformation typeInfo=uriParseTreeVisitor.new TypeInformation(myType.type,typed.isCollection());
        context.contextTypes.push(typeInfo);
      }
      readQueryParameter=true;
    }
    if (readQueryParameter) {
      for (      RawUri.QueryOption option : uri.queryOptionListDecoded) {
        if (!option.name.startsWith("String_Node_Str")) {
          CustomQueryOptionImpl customOption=new CustomQueryOptionImpl();
          customOption.setName(option.name);
          customOption.setText(option.value);
          context.contextUriInfo.addCustomQueryOption(customOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.FILTER.toString())) {
          FilterExpressionEOFContext ctxFilterExpression=(FilterExpressionEOFContext)parseRule(option.value,ParserEntryRules.FilterExpression);
          FilterOptionImpl filterOption=(FilterOptionImpl)uriParseTreeVisitor.visitFilterExpressionEOF(ctxFilterExpression);
          context.contextUriInfo.setSystemQueryOption(filterOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.FORMAT.toString())) {
          FormatOptionImpl formatOption=new FormatOptionImpl();
          formatOption.setName(option.name);
          formatOption.setText(option.value);
          if (option.value.equalsIgnoreCase(ODataFormat.JSON.name()) || option.value.equalsIgnoreCase(ODataFormat.XML.name()) || option.value.equalsIgnoreCase(ODataFormat.ATOM.name())|| isFormatSyntaxValid(option)) {
            formatOption.setFormat(option.value);
          }
 else {
            throw new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION_FORMAT,option.value);
          }
          context.contextUriInfo.setSystemQueryOption(formatOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.EXPAND.toString())) {
          ExpandItemsEOFContext ctxExpandItems=(ExpandItemsEOFContext)parseRule(option.value,ParserEntryRules.ExpandItems);
          ExpandOptionImpl expandOption=(ExpandOptionImpl)uriParseTreeVisitor.visitExpandItemsEOF(ctxExpandItems);
          context.contextUriInfo.setSystemQueryOption(expandOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.ID.toString())) {
          IdOptionImpl idOption=new IdOptionImpl();
          idOption.setName(option.name);
          idOption.setText(option.value);
          idOption.setValue(option.value);
          context.contextUriInfo.setSystemQueryOption(idOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.LEVELS.toString())) {
          throw new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.SYSTEM_QUERY_OPTION_LEVELS_NOT_ALLOWED_HERE);
        }
 else         if (option.name.equals(SystemQueryOptionKind.ORDERBY.toString())) {
          OrderByEOFContext ctxOrderByExpression=(OrderByEOFContext)parseRule(option.value,ParserEntryRules.Orderby);
          OrderByOptionImpl orderByOption=(OrderByOptionImpl)uriParseTreeVisitor.visitOrderByEOF(ctxOrderByExpression);
          context.contextUriInfo.setSystemQueryOption(orderByOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.SEARCH.toString())) {
          throw new RuntimeException("String_Node_Str");
        }
 else         if (option.name.equals(SystemQueryOptionKind.SELECT.toString())) {
          SelectEOFContext ctxSelectEOF=(SelectEOFContext)parseRule(option.value,ParserEntryRules.Select);
          SelectOptionImpl selectOption=(SelectOptionImpl)uriParseTreeVisitor.visitSelectEOF(ctxSelectEOF);
          context.contextUriInfo.setSystemQueryOption(selectOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.SKIP.toString())) {
          SkipOptionImpl skipOption=new SkipOptionImpl();
          skipOption.setName(option.name);
          skipOption.setText(option.value);
          try {
            skipOption.setValue(Integer.parseInt(option.value));
          }
 catch (          final NumberFormatException e) {
            throw new UriParserSyntaxException("String_Node_Str",e,UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION,option.name,option.value);
          }
          context.contextUriInfo.setSystemQueryOption(skipOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.SKIPTOKEN.toString())) {
          SkipTokenOptionImpl skipTokenOption=new SkipTokenOptionImpl();
          skipTokenOption.setName(option.name);
          skipTokenOption.setText(option.value);
          skipTokenOption.setValue(option.value);
          context.contextUriInfo.setSystemQueryOption(skipTokenOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.TOP.toString())) {
          TopOptionImpl topOption=new TopOptionImpl();
          topOption.setName(option.name);
          topOption.setText(option.value);
          try {
            topOption.setValue(Integer.parseInt(option.value));
          }
 catch (          final NumberFormatException e) {
            throw new UriParserSyntaxException("String_Node_Str",e,UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION,option.name,option.value);
          }
          context.contextUriInfo.setSystemQueryOption(topOption);
        }
 else         if (option.name.equals(SystemQueryOptionKind.COUNT.toString())) {
          CountOptionImpl inlineCountOption=new CountOptionImpl();
          inlineCountOption.setName(option.name);
          inlineCountOption.setText(option.value);
          if (option.value.equals("String_Node_Str") || option.value.equals("String_Node_Str")) {
            inlineCountOption.setValue(Boolean.parseBoolean(option.value));
          }
 else {
            throw new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION,option.name,option.value);
          }
          context.contextUriInfo.setSystemQueryOption(inlineCountOption);
        }
 else {
          throw new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.UNKNOWN_SYSTEM_QUERY_OPTION,option.name);
        }
      }
    }
    if (readFragment) {
      context.contextUriInfo.setFragment(uri.fragment);
    }
    return context.contextUriInfo;
  }
 catch (  ParseCancellationException e) {
    throw e.getCause() instanceof UriParserException ? (UriParserException)e.getCause() : new UriParserSyntaxException("String_Node_Str",e,UriParserSyntaxException.MessageKeys.SYNTAX);
  }
}

Fixed version (ground truth):
public UriInfo parseUri(final String input,final Edm edm) throws UriParserException {
  boolean readQueryParameter=false;
  boolean readFragment=false;
  UriContext context=new UriContext();
  UriParseTreeVisitor uriParseTreeVisitor=new UriParseTreeVisitor(edm,context);
  try {
    RawUri uri=UriDecoder.decodeUri(input,0);
    String firstSegment="String_Node_Str";
    if (uri.pathSegmentListDecoded.size() > 0) {
      firstSegment=uri.pathSegmentListDecoded.get(0);
    }
    if (firstSegment.length() == 0) {
      readQueryParameter=true;
      context.contextUriInfo=new UriInfoImpl().setKind(UriInfoKind.service);
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      BatchEOFContext ctxBatchEOF=(BatchEOFContext)parseRule(uri.pathSegmentListDecoded.get(0),ParserEntryRules.Batch);
      uriParseTreeVisitor.visitBatchEOF(ctxBatchEOF);
      readQueryParameter=true;
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      MetadataEOFContext ctxMetadataEOF=(MetadataEOFContext)parseRule(uri.pathSegmentListDecoded.get(0),ParserEntryRules.Metadata);
      uriParseTreeVisitor.visitMetadataEOF(ctxMetadataEOF);
      readQueryParameter=true;
      readFragment=true;
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      context.contextUriInfo=new UriInfoImpl().setKind(UriInfoKind.entityId);
      if (uri.pathSegmentListDecoded.size() > 1) {
        EntityEOFContext ctxEntityEOF=(EntityEOFContext)parseRule(uri.pathSegmentListDecoded.get(1),ParserEntryRules.Entity);
        uriParseTreeVisitor.visitEntityEOF(ctxEntityEOF);
      }
      readQueryParameter=true;
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      AllEOFContext ctxResourcePathEOF=(AllEOFContext)parseRule(uri.pathSegmentListDecoded.get(0),ParserEntryRules.All);
      uriParseTreeVisitor.visitAllEOF(ctxResourcePathEOF);
      readQueryParameter=true;
    }
 else     if (firstSegment.startsWith("String_Node_Str")) {
      CrossjoinEOFContext ctxResourcePathEOF=(CrossjoinEOFContext)parseRule(uri.pathSegmentListDecoded.get(0),ParserEntryRules.CrossJoin);
      uriParseTreeVisitor.visitCrossjoinEOF(ctxResourcePathEOF);
      readQueryParameter=true;
    }
 else {
      List<PathSegmentEOFContext> ctxPathSegments=new ArrayList<PathSegmentEOFContext>();
      for (      String pathSegment : uri.pathSegmentListDecoded) {
        PathSegmentEOFContext ctxPathSegment=(PathSegmentEOFContext)parseRule(pathSegment,ParserEntryRules.PathSegment);
        ctxPathSegments.add(ctxPathSegment);
      }
      context.contextUriInfo=new UriInfoImpl().setKind(UriInfoKind.resource);
      for (      PathSegmentEOFContext ctxPathSegment : ctxPathSegments) {
        uriParseTreeVisitor.visitPathSegmentEOF(ctxPathSegment);
      }
      UriResource lastSegment=context.contextUriInfo.getLastResourcePart();
      if (lastSegment instanceof UriResourcePartTyped) {
        UriResourcePartTyped typed=(UriResourcePartTyped)lastSegment;
        UriParseTreeVisitor.TypeInformation myType=uriParseTreeVisitor.getTypeInformation(typed);
        UriParseTreeVisitor.TypeInformation typeInfo=uriParseTreeVisitor.new TypeInformation(myType.type,typed.isCollection());
        context.contextTypes.push(typeInfo);
      }
      readQueryParameter=true;
    }
    if (readQueryParameter) {
      for (      RawUri.QueryOption option : uri.queryOptionListDecoded) {
        if (option.name.startsWith("String_Node_Str")) {
          SystemQueryOption systemOption=null;
          if (option.name.equals(SystemQueryOptionKind.FILTER.toString())) {
            FilterExpressionEOFContext ctxFilterExpression=(FilterExpressionEOFContext)parseRule(option.value,ParserEntryRules.FilterExpression);
            FilterOptionImpl filterOption=(FilterOptionImpl)uriParseTreeVisitor.visitFilterExpressionEOF(ctxFilterExpression);
            systemOption=filterOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.FORMAT.toString())) {
            FormatOptionImpl formatOption=new FormatOptionImpl();
            formatOption.setName(option.name);
            formatOption.setText(option.value);
            if (option.value.equalsIgnoreCase(ODataFormat.JSON.name()) || option.value.equalsIgnoreCase(ODataFormat.XML.name()) || option.value.equalsIgnoreCase(ODataFormat.ATOM.name())|| isFormatSyntaxValid(option)) {
              formatOption.setFormat(option.value);
            }
 else {
              throw new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION_FORMAT,option.value);
            }
            systemOption=formatOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.EXPAND.toString())) {
            ExpandItemsEOFContext ctxExpandItems=(ExpandItemsEOFContext)parseRule(option.value,ParserEntryRules.ExpandItems);
            ExpandOptionImpl expandOption=(ExpandOptionImpl)uriParseTreeVisitor.visitExpandItemsEOF(ctxExpandItems);
            systemOption=expandOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.ID.toString())) {
            IdOptionImpl idOption=new IdOptionImpl();
            idOption.setName(option.name);
            idOption.setText(option.value);
            idOption.setValue(option.value);
            systemOption=idOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.LEVELS.toString())) {
            throw new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.SYSTEM_QUERY_OPTION_LEVELS_NOT_ALLOWED_HERE);
          }
 else           if (option.name.equals(SystemQueryOptionKind.ORDERBY.toString())) {
            OrderByEOFContext ctxOrderByExpression=(OrderByEOFContext)parseRule(option.value,ParserEntryRules.Orderby);
            OrderByOptionImpl orderByOption=(OrderByOptionImpl)uriParseTreeVisitor.visitOrderByEOF(ctxOrderByExpression);
            systemOption=orderByOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.SEARCH.toString())) {
            throw new RuntimeException("String_Node_Str");
          }
 else           if (option.name.equals(SystemQueryOptionKind.SELECT.toString())) {
            SelectEOFContext ctxSelectEOF=(SelectEOFContext)parseRule(option.value,ParserEntryRules.Select);
            SelectOptionImpl selectOption=(SelectOptionImpl)uriParseTreeVisitor.visitSelectEOF(ctxSelectEOF);
            systemOption=selectOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.SKIP.toString())) {
            SkipOptionImpl skipOption=new SkipOptionImpl();
            skipOption.setName(option.name);
            skipOption.setText(option.value);
            try {
              skipOption.setValue(Integer.parseInt(option.value));
            }
 catch (            final NumberFormatException e) {
              throw new UriParserSyntaxException("String_Node_Str",e,UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION,option.name,option.value);
            }
            systemOption=skipOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.SKIPTOKEN.toString())) {
            SkipTokenOptionImpl skipTokenOption=new SkipTokenOptionImpl();
            skipTokenOption.setName(option.name);
            skipTokenOption.setText(option.value);
            skipTokenOption.setValue(option.value);
            systemOption=skipTokenOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.TOP.toString())) {
            TopOptionImpl topOption=new TopOptionImpl();
            topOption.setName(option.name);
            topOption.setText(option.value);
            try {
              topOption.setValue(Integer.parseInt(option.value));
            }
 catch (            final NumberFormatException e) {
              throw new UriParserSyntaxException("String_Node_Str",e,UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION,option.name,option.value);
            }
            systemOption=topOption;
          }
 else           if (option.name.equals(SystemQueryOptionKind.COUNT.toString())) {
            CountOptionImpl inlineCountOption=new CountOptionImpl();
            inlineCountOption.setName(option.name);
            inlineCountOption.setText(option.value);
            if (option.value.equals("String_Node_Str") || option.value.equals("String_Node_Str")) {
              inlineCountOption.setValue(Boolean.parseBoolean(option.value));
            }
 else {
              throw new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION,option.name,option.value);
            }
            systemOption=inlineCountOption;
          }
 else {
            throw new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.UNKNOWN_SYSTEM_QUERY_OPTION,option.name);
          }
          try {
            context.contextUriInfo.setSystemQueryOption(systemOption);
          }
 catch (          final ODataRuntimeException e) {
            throw new UriParserSyntaxException("String_Node_Str",e,UriParserSyntaxException.MessageKeys.DOUBLE_SYSTEM_QUERY_OPTION,option.name);
          }
        }
 else {
          CustomQueryOptionImpl customOption=new CustomQueryOptionImpl();
          customOption.setName(option.name);
          customOption.setText(option.value);
          context.contextUriInfo.addCustomQueryOption(customOption);
        }
      }
    }
    if (readFragment) {
      context.contextUriInfo.setFragment(uri.fragment);
    }
    return context.contextUriInfo;
  }
 catch (  ParseCancellationException e) {
    throw e.getCause() instanceof UriParserException ? (UriParserException)e.getCause() : new UriParserSyntaxException("String_Node_Str",e,UriParserSyntaxException.MessageKeys.SYNTAX);
  }
}