Skip to content

Eyjafjallajokull-Roman/maven-proxy-auth-repro

Repository files navigation

Maven proxy auth repro (Maven 3.9.x + Squid)

This repo reproduces a proxy-auth problem with Maven 3.9.x (Aether HttpTransporter) when using a Squid proxy that requires Basic authentication.

Prerequisites

  • Docker Desktop (Windows)
  • docker compose available in PATH

Start containers

docker compose up -d

Sanity check (proxy works with curl)

docker exec -it mvn3911 bash -lc "
apt-get update >/dev/null 2>&1 || true &&
apt-get install -y curl >/dev/null 2>&1 || true &&
curl -I -x http://artifact:artifact@squid-test:3128 https://repo.maven.apache.org/maven2/ | head -n 30"

Expected: HTTP/1.1 200 (or 3xx) and no 407.

Important: ensure clean Maven repository

To reliably reproduce the issue, Maven must download artifacts through the proxy. After every test run, the Maven local repository must be cleaned so cached artifacts do not hide the problem.

Option A: wipe the Maven volume (recommended)

docker compose down -v
docker compose up -d

Option B: clean inside the container

docker exec -it mvn3911 bash -lc "rm -rf /root/.m2/repository/*"

You must do this: before the failing multithread run and again before the single-thread workaround run Otherwise Maven may reuse cached artifacts and bypass the proxy.

This is required so Maven is forced to download artifacts through the proxy.

Repro (expected FAIL / intermittent 407)

Run Maven with debug and force update using the provided settings:

docker exec -it mvn3911 bash -lc "
cd /work &&
mvn -U -X -B -Dstyle.color=never -s /work/settings.xml clean verify 2>&1 | tee /work/maven-proxy.log"

Expected: build fails with 407 Proxy Authentication Required. In Squid log you may see requests with ProxyAuth:- (missing header) before auth succeeds.

Workaround (expected PASS)

Limit Maven artifact resolver threads:

docker exec -it mvn3911 bash -lc "
cd /work &&
mvn -U -X -B -Dstyle.color=never -Dmaven.artifact.threads=1 -s /work/settings.xml clean verify 2>&1 | tee /work/maven-proxy-threads1.log"

Expected: build succeeds (or the 407 disappears).

Logs for issue report

Maven logs:

maven-proxy.log — FAIL run (multithread)

maven-proxy-threads1.log — PASS run (single thread)

This repo also includes pre-generated logs:

maven-multithread.log

maven-singlethread.log

Squid log:

docker exec -it squid-test bash -lc 'tail -n 200 /var/log/squid/access.log'

Cleanup

docker compose down -v

About

Reproduce bug for maven issue github

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages