Versions: - Spring Boot 3.0.1 - Spring Cloud 2022.0.0 - Kubernetes v1.22.11

Description: Spring application cannot resolve requests containing cookies when running in a Kubernetes cluster. However, running the application locally from the IDE works just fine. Did not experience this issue with Spring Boot 2.7.6 and Spring Cloud 2021.0.5.

Given the application is deployed in a Kubernetes cluster, the following requests have been sent from the pod itself.

Request without a cookie:

curl 'http://localhost:80/management/health' 
{"status":"UP","groups":["liveness","readiness"]}

Request with cookie:

curl 'http://localhost:80/management/health' -H 'cookie: foo=bar'                                                                                                   
{"timestamp":"2023-01-09T14:15:48.105+00:00","status":404,"error":"Not Found","path":"barnagement/health"}

Server log:

{
   "timestamp":"2023-01-09 14:21:51.840",
   "logger":"org.springframework.web.servlet.PageNotFound",
   "level":"WARN",
   "message":"No mapping for foo barnagement/health"
}

Comment From: wilkinsona

Does the problem occur without Spring Cloud?

Comment From: rob-oberbeck

Removed all the application code besides the main and removed Spring Cloud dependencies. However, still facing the very same issue.

I'm using Spring actuator in this example but experienced the same behaviour with @RequestMapping.

Comment From: wilkinsona

Thanks for trying things with a more minimal setup. It appears that something is using the value of the foo cookie to rewrite the URL. When you've set it to bar, the request to management/health has become a request to barnagement/health or perhaps foo barnagement/health.

I've never seen anything like this before, either with Kubernetes or without. As such, I am inclined to suspect that something in your K8S enviroment is causing the problem. What is listening on port 80? It's quite unusual for a Boot app to listen directly on port 80. If it's something else that's routing requests to the Boot application, what is it and how is it configured?

Comment From: rob-oberbeck

Changing the port to 8080 and Docker image from mcr.microsoft.com/java/jdk:17-zulu-ubuntu to openjdk:17-alpine as build resolved the issue, at least for the minimal setup (Spring Boot without Spring Cloud and only a main method). Unfortunately, the issue remains the same when running the complete application with an alpine image. Interestingly, I only experience this behaviour in Kubernetes, everything works fine when running the Docker image on my local machine.

We'll have to do more investigation on our end to find the root cause. For now we'll continue using Spring Boot 2.7.7.

Comment From: philwebb

@rob-oberbeck I'll close this one for now whilst you investigate. If you're able to create a simple reproducer, please let us know and we can reopen it.

Comment From: cxjava

Same issue from our application.

Strange things is that: we have two application, one application can work fine with cookie, other application can't work fine, both are same spring boot version 3.0.1.

Comment From: cxjava

@rob-oberbeck After our application upgrade com.datadoghq:dd-java-agent to 1.3.0, then fix this issue.

Comment From: rob-oberbeck

Did the same to fix the issue.

Thank you!