In th springboot project, I have to build a link asynchronously. But inside CompletableFuture method, HttpServletRequest's getScheme() & getServerName() methods are returning null.
And few days back it was working fine but since some time it is returning null.
public void printUrl(HttpServletRequest request) {
//Working Fine here
System.out.println("URL is - "+request.getScheme()+"//:"+request.getServerName()+"/mylink");
CompletableFuture<Integer> asyncSendReadyEmail = CompletableFuture.supplyAsync(() -> {
//Not Working here
System.out.println("URL is - "+request.getScheme()+"//:"+request.getServerName()+"/mylink");
return 1;
});
System.out.println("Return from this method");
}
Can anyone help me out, what is the reason behind it.