File tree Expand file tree Collapse file tree
java/org/openrewrite/maven Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ dependencies {
4343 testImplementation(" com.squareup.okio:okio-jvm:3.9.1" )
4444 testImplementation(" org.mapdb:mapdb:latest.release" )
4545
46+ testRuntimeOnly(" org.slf4j:jul-to-slf4j:latest.release" )
4647 testRuntimeOnly(" org.mapdb:mapdb:latest.release" )
4748 testRuntimeOnly(project(" :rewrite-java-21" ))
4849 testRuntimeOnly(" org.rocksdb:rocksdbjni:10.2.1" )
@@ -62,6 +63,10 @@ tasks.register<JavaExec>("generateAntlrSources") {
6263 finalizedBy(" licenseFormat" )
6364}
6465
66+ tasks.withType<Test >().configureEach {
67+ jvmArgs(" -Djava.util.logging.config.file=${file(" src/test/resources/logging.properties" ).absolutePath} " )
68+ }
69+
6570tasks.withType<Javadoc >().configureEach {
6671 // generated ANTLR sources violate doclint
6772 (options as StandardJavadocDocletOptions ).addStringOption(" Xdoclint:none" , " -quiet" )
Original file line number Diff line number Diff line change @@ -984,7 +984,6 @@ void dependencyScopeTakesPrecedenceOverDependencyManagementScope() {
984984 @ Test
985985 void mirrorsAndAuth () throws Exception {
986986 // Set up a web server that returns 401 to any request without an Authorization header corresponding to specific credentials
987- // Exceptions in the console output are due to MavenPomDownloader attempting to access via https first before falling back to http
988987 var username = "admin" ;
989988 var password = "password" ;
990989 try (var mockRepo = new MockWebServer ()) {
Original file line number Diff line number Diff line change @@ -346,7 +346,16 @@ void normalizeRejectConnectException() {
346346 void useHttpWhenHttpsFails () throws Exception {
347347 var downloader = new MavenPomDownloader (emptyMap (), ctx );
348348 try (var mockRepo = new MockWebServer ()) {
349- mockRepo .enqueue (new MockResponse ().setResponseCode (200 ).setBody ("body" ));
349+ // Use a Dispatcher instead of enqueue to avoid flakiness: normalizeRepository()
350+ // probes HTTPS first, and TLS bytes sent to this HTTP-only server can sometimes
351+ // parse as valid HTTP, consuming an enqueued response before the real HTTP request.
352+ mockRepo .setDispatcher (new Dispatcher () {
353+ @ Override
354+ public MockResponse dispatch (RecordedRequest recordedRequest ) {
355+ return new MockResponse ().setResponseCode (200 ).setBody ("body" );
356+ }
357+ });
358+ mockRepo .start ();
350359 var httpRepo = MavenRepository .builder ()
351360 .id ("id" )
352361 .uri ("http://%s:%d/maven/" .formatted (mockRepo .getHostName (), mockRepo .getPort ()))
Original file line number Diff line number Diff line change 1+ #
2+ # Copyright 2025 the original author or authors.
3+ # <p>
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ # <p>
8+ # https://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ #
16+
17+ # Route java.util.logging through SLF4J, which uses slf4j-nop in tests.
18+ # This suppresses spurious MockWebServer crash logs caused by
19+ # normalizeRepository() probing HTTPS on HTTP-only mock servers.
20+ handlers = org.slf4j.bridge.SLF4JBridgeHandler
You can’t perform that action at this time.
0 commit comments