Skip to content

Commit 4111730

Browse files
committed
8359364: java/net/URL/EarlyOrDelayedParsing test fails intermittently
Reviewed-by: alanb Backport-of: 57cabc6
1 parent 74ea38e commit 4111730

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/jdk/java/net/URL/EarlyOrDelayedParsing.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,10 @@
3838
import java.io.IOException;
3939
import java.net.ConnectException;
4040
import java.net.MalformedURLException;
41+
import java.net.Proxy;
42+
import java.net.ProxySelector;
43+
import java.net.SocketAddress;
44+
import java.net.URI;
4145
import java.net.URL;
4246
import java.net.UnknownHostException;
4347
import java.util.ArrayList;
@@ -57,6 +61,19 @@ public class EarlyOrDelayedParsing {
5761
{
5862
String value = System.getProperty("jdk.net.url.delayParsing", "false");
5963
EARLY_PARSING = !value.isEmpty() && !Boolean.parseBoolean(value);
64+
if (!EARLY_PARSING) {
65+
// we will open the connection in that case.
66+
// make sure no proxy is selected
67+
ProxySelector.setDefault(new ProxySelector() {
68+
@Override
69+
public List<Proxy> select(URI uri) {
70+
return List.of(Proxy.NO_PROXY);
71+
}
72+
@Override
73+
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
74+
}
75+
});
76+
}
6077
}
6178

6279
// Some characters that when included at the wrong place

0 commit comments

Comments
 (0)