Program: 175801
Project: 175801
Buggy source:
@Override public void getConnection(ProxyTarget target,HttpServerExchange exchange,ProxyCallback<ProxyConnection> callback,long timeout,TimeUnit timeUnit){
  Realm realm=realmCache.matches(exchange.getRequestPath());
  if (realm != null) {
    parseToken(exchange).ifPresent(token -> {
      Optional<UserPermissionPrincipal> principal=authenticate(realm.getId(),token);
      principal.ifPresent(p -> {
        Map<String,Object> body=new HashMap<>();
        body.put("String_Node_Str",p.getName());
        body.put("String_Node_Str",p.getPermissions());
        p.getProfiles().forEach((k,v) -> {
          body.put(k,v);
        }
);
        exchange.getRequestHeaders().put(HttpString.tryFromString(config.getBackendHeaderName()),jwt.sign(body,jwtHeader,null));
      }
);
    }
);
  }
 else {
    exchange.setStatusCode(404);
    exchange.endExchange();
    return;
  }
  Application application=realmCache.getApplication(realm);
  ClientConnection existing=exchange.getConnection().getAttachment(clientAttachmentKey);
  if (existing != null) {
    if (existing.isOpen()) {
      String path=exchange.getRequestPath();
      if (path.startsWith(application.getVirtualPath())) {
        String passTo=calculatePathTo(path,application);
        exchange.setRequestPath(passTo);
        exchange.setRequestURI(passTo);
      }
      callback.completed(exchange,new ProxyConnection(existing,"String_Node_Str"));
      return;
    }
 else {
      exchange.getConnection().removeAttachment(clientAttachmentKey);
    }
  }
  try {
    URI uri=application.getUriToPass();
    client.connect(new ConnectNotifier(callback,exchange),new URI(uri.getScheme(),null,uri.getHost(),uri.getPort(),null,null,null),exchange.getIoThread(),exchange.getConnection().getByteBufferPool(),OptionMap.EMPTY);
  }
 catch (  URISyntaxException e) {
    throw new MisconfigurationException("String_Node_Str",application.getUriToPass(),e);
  }
}

Fixed version (ground truth):
@Override public void getConnection(ProxyTarget target,HttpServerExchange exchange,ProxyCallback<ProxyConnection> callback,long timeout,TimeUnit timeUnit){
  Realm realm=realmCache.matches(exchange.getRequestPath());
  if (realm != null) {
    parseToken(exchange).ifPresent(token -> {
      Optional<UserPermissionPrincipal> principal=authenticate(realm.getId(),token);
      principal.ifPresent(p -> {
        Map<String,Object> body=new HashMap<>();
        body.put("String_Node_Str",p.getName());
        body.put("String_Node_Str",p.getPermissions());
        p.getProfiles().forEach((k,v) -> {
          body.put(k,v);
        }
);
        exchange.getRequestHeaders().put(HttpString.tryFromString(config.getBackendHeaderName()),jwt.sign(body,jwtHeader,null));
      }
);
    }
);
  }
 else {
    exchange.setStatusCode(404);
    exchange.endExchange();
    return;
  }
  Application application=realmCache.getApplication(realm);
  ClientConnection existing=exchange.getConnection().getAttachment(clientAttachmentKey);
  if (existing != null) {
    if (existing.isOpen()) {
      String path=exchange.getRequestURI();
      if (path.startsWith(application.getVirtualPath())) {
        String passTo=calculatePathTo(path,application);
        exchange.setRequestPath(passTo);
        exchange.setRequestURI(passTo);
      }
      callback.completed(exchange,new ProxyConnection(existing,"String_Node_Str"));
      return;
    }
 else {
      exchange.getConnection().removeAttachment(clientAttachmentKey);
    }
  }
  try {
    URI uri=application.getUriToPass();
    client.connect(new ConnectNotifier(callback,exchange),new URI(uri.getScheme(),null,uri.getHost(),uri.getPort(),null,null,null),exchange.getIoThread(),exchange.getConnection().getByteBufferPool(),OptionMap.EMPTY);
  }
 catch (  URISyntaxException e) {
    throw new MisconfigurationException("String_Node_Str",application.getUriToPass(),e);
  }
}