changeset 13365:c7415e1be29b

7185576: Need to consider the connection timeout at test/com/sun/jndi/ldap/InvalidLdapFilters.java Reviewed-by: vinnie
author xuelei
date Tue, 24 Jul 2012 03:31:44 -0700
parents 67ebd60432ce
children 2f5fdf6d8c22
files jdk/test/com/sun/jndi/ldap/InvalidLdapFilters.java
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/test/com/sun/jndi/ldap/InvalidLdapFilters.java	Tue Jul 24 09:20:44 2012 +0800
+++ b/jdk/test/com/sun/jndi/ldap/InvalidLdapFilters.java	Tue Jul 24 03:31:44 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -171,7 +171,21 @@
         // env.put(Context.SECURITY_CREDENTIALS,"root");
 
         // create initial context
-        DirContext context = new InitialDirContext(env);
+        DirContext context = null;
+        int i = 0;
+        while (true) {
+            try {
+                context = new InitialDirContext(env);
+                break;
+            } catch (NamingException ne) {
+                // may be a connection or read timeout, try again
+                // no more than 5 times
+                if (i++ > 5) {
+                    throw new Exception(
+                        "Maybe timeout during context initialization", ne);
+                }
+            }
+        }
 
         // searching
         SearchControls scs = new SearchControls();