From 2dc073d0f37048372498e13ffe84455896bac945 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 18 May 2015 22:47:48 +0000
Subject: [PATCH] AutoRefactor'ed Use diamond operator
---
opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java | 31 ++++++++-----------------------
1 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java b/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
index db27b27..a02e77a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
@@ -103,13 +103,7 @@
String pwd, int timeout, Hashtable<String, String> env)
throws NamingException
{
- if (env != null)
- { // We clone 'env' so that we can modify it freely
- env = new Hashtable<String, String>(env);
- } else
- {
- env = new Hashtable<String, String>();
- }
+ env = copy(env);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put("java.naming.ldap.attributes.binary",
@@ -183,13 +177,7 @@
public static InitialLdapContext createLdapsContext(String ldapsURL,
String dn, String pwd, int timeout, Hashtable<String, String> env,
TrustManager trustManager, KeyManager keyManager) throws NamingException {
- if (env != null)
- { // We clone 'env' so that we can modify it freely
- env = new Hashtable<String, String>(env);
- } else
- {
- env = new Hashtable<String, String>();
- }
+ env = copy(env);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put("java.naming.ldap.attributes.binary",
@@ -331,14 +319,7 @@
verifier = new BlindHostnameVerifier();
}
- if (env != null)
- { // We clone 'env' to modify it freely
- env = new Hashtable<String, String>(env);
- }
- else
- {
- env = new Hashtable<String, String>();
- }
+ env = copy(env);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put("java.naming.ldap.attributes.binary",
@@ -401,6 +382,10 @@
return getInitialLdapContext(t, pair, timeout);
}
+ private static Hashtable<String, String> copy(Hashtable<String, String> env) {
+ return env != null ? new Hashtable<>(env) : new Hashtable<String, String>();
+ }
+
/**
* Returns the LDAP URL used in the provided InitialLdapContext.
* @param ctx the context to analyze.
@@ -791,7 +776,7 @@
public static Set<String> getValues(SearchResult entry, String attrName)
throws NamingException
{
- Set<String> values = new HashSet<String>();
+ Set<String> values = new HashSet<>();
Attributes attrs = entry.getAttributes();
if (attrs != null)
{
--
Gitblit v1.10.0