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

Commit d41400c

Browse files
Alexey BakhtinYuri Nesterenko
authored andcommitted
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
Backport-of: 49a4d4b
1 parent 95d9a1c commit d41400c

File tree

5 files changed

+443
-358
lines changed

5 files changed

+443
-358
lines changed

src/java.naming/share/classes/com/sun/jndi/ldap/DefaultLdapDnsProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019, 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
@@ -76,7 +76,7 @@ public Optional<LdapDnsProviderResult> lookupEndpoints(String url,
7676
}
7777

7878
LdapDnsProviderResult res = new LdapDnsProviderResult(domainName, endpoints);
79-
if (res.getEndpoints().size() == 0 && res.getDomainName().isEmpty()) {
79+
if (res.getEndpoints().isEmpty() && res.getDomainName().isEmpty()) {
8080
return Optional.empty();
8181
} else {
8282
return Optional.of(res);

src/java.naming/share/classes/com/sun/jndi/ldap/LdapDnsProviderService.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019, 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
@@ -37,6 +37,8 @@
3737
* The {@code LdapDnsProviderService} is responsible for creating and providing
3838
* access to the registered {@code LdapDnsProvider}s. The {@link ServiceLoader}
3939
* is used to find and register any implementations of {@link LdapDnsProvider}.
40+
*
41+
* <p> Instances of this class are safe for use by multiple threads.
4042
*/
4143
final class LdapDnsProviderService {
4244

@@ -68,19 +70,19 @@ private LdapDnsProviderService() {
6870
}
6971

7072
/**
71-
* Retrieve the singleton static instance of LdapDnsProviderService.
73+
* Retrieves the singleton instance of LdapDnsProviderService.
7274
*/
7375
static LdapDnsProviderService getInstance() {
7476
if (service != null) return service;
75-
synchronized(LOCK) {
77+
synchronized (LOCK) {
7678
if (service != null) return service;
7779
service = new LdapDnsProviderService();
7880
}
7981
return service;
8082
}
8183

8284
/**
83-
* Retrieve result from the first provider that successfully resolves
85+
* Retrieves result from the first provider that successfully resolves
8486
* the endpoints. If no results are found when calling installed
8587
* subclasses of {@code LdapDnsProvider} then this method will fall back
8688
* to the {@code DefaultLdapDnsProvider}.
@@ -91,14 +93,15 @@ static LdapDnsProviderService getInstance() {
9193
LdapDnsProviderResult lookupEndpoints(String url, Hashtable<?,?> env)
9294
throws NamingException
9395
{
94-
Iterator<LdapDnsProvider> iterator = providers.iterator();
95-
Hashtable<?, ?> envCopy = new Hashtable<>(env);
9696
LdapDnsProviderResult result = null;
97-
98-
while (result == null && iterator.hasNext()) {
99-
result = iterator.next().lookupEndpoints(url, envCopy)
100-
.filter(r -> r.getEndpoints().size() > 0)
101-
.orElse(null);
97+
Hashtable<?, ?> envCopy = new Hashtable<>(env);
98+
synchronized (LOCK) {
99+
Iterator<LdapDnsProvider> iterator = providers.iterator();
100+
while (result == null && iterator.hasNext()) {
101+
result = iterator.next().lookupEndpoints(url, envCopy)
102+
.filter(r -> !r.getEndpoints().isEmpty())
103+
.orElse(null);
104+
}
102105
}
103106

104107
if (result == null) {

test/jdk/ProblemList.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,6 @@ sun/tools/jhsdb/HeapDumpTest.java 8193639 solaris-
944944

945945
com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java 8169942 linux-i586,macosx-all,windows-x64
946946

947-
com/sun/jndi/ldap/LdapTimeoutTest.java 8151678 generic-all
948-
949947
com/sun/jndi/dns/ConfigTests/PortUnreachable.java 7164518 macosx-all
950948

951949
javax/rmi/ssl/SSLSocketParametersTest.sh 8162906 generic-all

0 commit comments

Comments
 (0)