Source:
<code>public void update(Map<String, ?> props) { if (props != null) { LOGGER.debug("Received an updated set of configurations for the LDAP Login Config."); if (connectionPoolServiceRegistration != null) { connectionPoolServiceRegistration.unregister(); } if (ldapConnectionPool != null) { ldapConnectionPool.close(); } ConnectionFactory ldapConnectionFactory = null; List<String> urls = new ArrayList<>(); Object urlsObj = props.get(LDAP_URL); <START> if (urlsObj instanceof String[]) { <END> urls.addAll(Arrays.asList((String[]) urlsObj)); } else { urls.add(urlsObj.toString()); } List<ConnectionFactory> connectionFactories = new ArrayList<>(); Boolean startTls = props.get(START_TLS) == null ? false : Boolean.parseBoolean(props.get(START_TLS).toString()); for (String url : urls) { connectionFactories.add(createLdapConnectionFactory(url, startTls)); } String loadBalancingAlgorithm = (String) props.get(LDAP_LOAD_BALANCING); Options options = Options.defaultOptions(); if (loadBalancingAlgorithm != null && loadBalancingAlgorithm.equalsIgnoreCase("failover")) { ldapConnectionFactory = Connections.newFailoverLoadBalancer(connectionFactories, options); } else { ldapConnectionFactory = Connections.newRoundRobinLoadBalancer(connectionFactories, options); } ldapConnectionPool = new GenericObjectPool<>( new LdapConnectionPooledObjectFactory(ldapConnectionFactory), createGenericPoolConfig(id), createGenericPoolAbandonConfig()); Dictionary<String, String> serviceProps = new DictionaryMap<>(); serviceProps.put("id", id); LOGGER.debug("Registering LdapConnectionPool"); connectionPoolServiceRegistration = context.registerService( GenericObjectPool.class.getName(), ldapConnectionPool, serviceProps); Module ldapModule = createLdapModule(props); ldapService.update(ldapModule); } }</code><technical_language>This block of code is repeated [here](<LINK_0> Consider making a helper class for similar functionality</technical_language>

Target:
public void update(Map<String, ?> props) { if (props != null) { LOGGER.debug("Received an updated set of configurations for the LDAP Login Config."); if (connectionPoolServiceRegistration != null) { connectionPoolServiceRegistration.unregister(); } if (ldapConnectionPool != null) { ldapConnectionPool.close(); } ConnectionFactory ldapConnectionFactory = null; List<String> urls = new ArrayList<>(); Object urlsObj = props.get(LDAP_URL); if (urlsObj instanceof String[]) { urls.addAll(Arrays.asList((String[]) urlsObj)); } else { urls.add(urlsObj.toString()); } List<ConnectionFactory> connectionFactories = new ArrayList<>(); Boolean startTls = props.get(START_TLS) != null && Boolean.parseBoolean(props.get(START_TLS).toString()); for (String url : urls) { connectionFactories.add(createLdapConnectionFactory(url, startTls)); } String loadBalancingAlgorithm = (String) props.get(LDAP_LOAD_BALANCING); Options options = Options.defaultOptions(); if (FAILOVER.equalsIgnoreCase(loadBalancingAlgorithm)) { ldapConnectionFactory = Connections.newFailoverLoadBalancer(connectionFactories, options); } else { ldapConnectionFactory = Connections.newRoundRobinLoadBalancer(connectionFactories, options); } ldapConnectionPool = new GenericObjectPool<>( new LdapConnectionPooledObjectFactory(ldapConnectionFactory), createGenericPoolConfig(id), createGenericPoolAbandonConfig()); Dictionary<String, String> serviceProps = new DictionaryMap<>(); serviceProps.put("id", id); LOGGER.debug("Registering LdapConnectionPool"); connectionPoolServiceRegistration = context.registerService( GenericObjectPool.class.getName(), ldapConnectionPool, serviceProps); Module ldapModule = createLdapModule(props); ldapService.update(ldapModule); } }