Program: 35275
Project: 35275
Buggy source:
@Override public void customize(ConfigurableEmbeddedServletContainer container){
  if (!(container instanceof TomcatEmbeddedServletContainerFactory)) {
    return;
  }
  TomcatEmbeddedServletContainerFactory containerFactory=(TomcatEmbeddedServletContainerFactory)container;
  containerFactory.addContextValves(new ValveBase(){
    @Override public void invoke(    Request request,    Response response) throws IOException, ServletException {
      int originalPort=-1;
      final String forwardedPort=request.getHeader("String_Node_Str");
      if (forwardedPort != null) {
        try {
          originalPort=request.getServerPort();
          request.setServerPort(Integer.valueOf(forwardedPort));
        }
 catch (        final NumberFormatException e) {
          logger.debug("String_Node_Str",forwardedPort);
        }
      }
      final MessageBytes serverNameMB=request.getCoyoteRequest().serverName();
      String originalServerName=null;
      String forwardedHost=request.getHeader("String_Node_Str");
      if (forwardedHost == null) {
        forwardedHost=request.getHeader("String_Node_Str");
      }
      if (forwardedHost != null) {
        int colonIndex=forwardedHost.indexOf("String_Node_Str");
        if (colonIndex > -1) {
          if (originalPort == -1) {
            originalPort=request.getServerPort();
          }
          request.setServerPort(Integer.valueOf(forwardedHost.substring(colonIndex + 1)));
          forwardedHost=forwardedHost.substring(0,colonIndex);
        }
        originalServerName=serverNameMB.getString();
        serverNameMB.setString(forwardedHost);
      }
      Boolean originallySecure=null;
      final String forwardedProto=request.getHeader("String_Node_Str");
      if (forwardedProto != null) {
        originallySecure=request.isSecure();
        request.setSecure(forwardedProto.equalsIgnoreCase("String_Node_Str"));
      }
      try {
        getNext().invoke(request,response);
      }
  finally {
        if (originallySecure != null) {
          request.setSecure(originallySecure);
        }
        if (forwardedHost != null) {
          serverNameMB.setString(originalServerName);
        }
        if (forwardedPort != null) {
          request.setServerPort(originalPort);
        }
      }
    }
  }
);
  ((TomcatEmbeddedServletContainerFactory)container).addContextCustomizers(context -> {
    context.setMapperContextRootRedirectEnabled(true);
  }
);
}

Fixed version (ground truth):
@Override public void customize(ConfigurableEmbeddedServletContainer container){
  if (!(container instanceof TomcatEmbeddedServletContainerFactory)) {
    return;
  }
  TomcatEmbeddedServletContainerFactory containerFactory=(TomcatEmbeddedServletContainerFactory)container;
  containerFactory.addContextValves(new ValveBase(){
    @Override public void invoke(    Request request,    Response response) throws IOException, ServletException {
      int originalPort=-1;
      final String forwardedPort=request.getHeader("String_Node_Str");
      if (forwardedPort != null) {
        try {
          originalPort=request.getServerPort();
          request.setServerPort(Integer.valueOf(forwardedPort));
        }
 catch (        final NumberFormatException e) {
          logger.debug("String_Node_Str",forwardedPort);
        }
      }
      final MessageBytes serverNameMB=request.getCoyoteRequest().serverName();
      String originalServerName=null;
      String forwardedHost=request.getHeader("String_Node_Str");
      if (forwardedHost == null) {
        forwardedHost=request.getHeader("String_Node_Str");
      }
      if (forwardedHost != null) {
        int colonIndex=forwardedHost.indexOf("String_Node_Str");
        if (colonIndex > -1) {
          if (originalPort == -1) {
            originalPort=request.getServerPort();
          }
          request.setServerPort(Integer.valueOf(forwardedHost.substring(colonIndex + 1)));
          forwardedHost=forwardedHost.substring(0,colonIndex);
        }
        originalServerName=serverNameMB.getString();
        serverNameMB.setString(forwardedHost);
      }
      Boolean originallySecure=null;
      final String forwardedProto=request.getHeader("String_Node_Str");
      if (forwardedProto != null) {
        originallySecure=request.isSecure();
        request.setSecure(forwardedProto.equalsIgnoreCase("String_Node_Str"));
      }
      try {
        getNext().invoke(request,response);
      }
  finally {
        if (originallySecure != null) {
          request.setSecure(originallySecure);
        }
        if (forwardedHost != null) {
          serverNameMB.setString(originalServerName);
        }
        if (forwardedPort != null) {
          request.setServerPort(originalPort);
        }
      }
    }
  }
);
  ((TomcatEmbeddedServletContainerFactory)container).addContextCustomizers(context -> context.setMapperContextRootRedirectEnabled(true));
}