Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 4623f5a

Browse files
author
Yuri Nesterenko
committed
8241138: http.nonProxyHosts=* causes StringIndexOutOfBoundsException in DefaultProxySelector
Reviewed-by: dcherepanov Backport-of: 59af1c2
1 parent 538464b commit 4623f5a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2020, 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
@@ -391,7 +391,9 @@ static Pattern toPattern(String mask) {
391391
*/
392392
static String disjunctToRegex(String disjunct) {
393393
String regex;
394-
if (disjunct.startsWith("*") && disjunct.endsWith("*")) {
394+
if (disjunct.equals("*")) {
395+
regex = ".*";
396+
} else if (disjunct.startsWith("*") && disjunct.endsWith("*")) {
395397
regex = ".*" + quote(disjunct.substring(1, disjunct.length() - 1)) + ".*";
396398
} else if (disjunct.startsWith("*")) {
397399
regex = ".*" + quote(disjunct.substring(1));

test/jdk/java/net/ProxySelector/B8035158.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, 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
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 8035158 8145732 8144300
26+
* @bug 8035158 8145732 8144300 8241138
2727
* @run main/othervm B8035158
2828
*/
2929

@@ -155,6 +155,12 @@ private static Collection<TestCase> misc() {
155155
false));
156156
t.add(new TestCase("*google.*", "http://google.co.uk",
157157
false));
158+
t.add(new TestCase("*", "http://google.co.uk",false));
159+
t.add(new TestCase("localhost|*", "http://google.co.uk",false));
160+
t.add(new TestCase("*|oracle.com", "http://google.co.uk",false));
161+
t.add(new TestCase("*|oracle.com|*", "http://google.co.uk",false));
162+
t.add(new TestCase("*|*", "http://google.co.uk",false));
163+
158164

159165
t.add(new TestCase("*oracle.com", "http://my.oracle.com", false));
160166
t.add(new TestCase("google.com|bing.com|yahoo.com", "http://127.0.0.1", false));

0 commit comments

Comments
 (0)