style: Simplifies code.

This commit is contained in:
Boris Grozev 2016-11-16 13:08:55 -06:00
parent 3e01bff25e
commit 99600368f6

View File

@ -132,15 +132,12 @@ public class HostCandidateHarvester
* Gets the list of explicitly allowed addresses. * Gets the list of explicitly allowed addresses.
* @return the list of explicitly allowed addresses. * @return the list of explicitly allowed addresses.
*/ */
public static List<InetAddress> getAllowedAddresses() public static synchronized List<InetAddress> getAllowedAddresses()
{
synchronized (HostCandidateHarvester.class)
{ {
if (!addressFiltersInitialized) if (!addressFiltersInitialized)
{ {
initializeAddressFilters(); initializeAddressFilters();
} }
}
return allowedAddresses; return allowedAddresses;
} }
@ -149,15 +146,12 @@ public class HostCandidateHarvester
* Gets the list of blocked addresses. * Gets the list of blocked addresses.
* @return the list of blocked addresses. * @return the list of blocked addresses.
*/ */
public static List<InetAddress> getBlockedAddresses() public static synchronized List<InetAddress> getBlockedAddresses()
{
synchronized (HostCandidateHarvester.class)
{ {
if (!addressFiltersInitialized) if (!addressFiltersInitialized)
{ {
initializeAddressFilters(); initializeAddressFilters();
} }
}
return blockedAddresses; return blockedAddresses;
} }
@ -166,12 +160,11 @@ public class HostCandidateHarvester
* Initializes the lists of allowed and blocked addresses according to the * Initializes the lists of allowed and blocked addresses according to the
* configuration properties. * configuration properties.
*/ */
private static void initializeAddressFilters() private static synchronized void initializeAddressFilters()
{
synchronized (HostCandidateHarvester.class)
{ {
if (addressFiltersInitialized) if (addressFiltersInitialized)
return; return;
addressFiltersInitialized = true;
String[] allowedAddressesStr String[] allowedAddressesStr
= StackProperties.getStringArray( = StackProperties.getStringArray(
@ -225,9 +218,6 @@ public class HostCandidateHarvester
blockedAddresses.add(address); blockedAddresses.add(address);
} }
} }
addressFiltersInitialized = true;
}
} }
/** /**