Source:
<code>public void onCustomizedStateRootChange(String instanceName, List<String> customizedStateTypes, NotificationContext changeContext) { logger.info("START: GenericClusterController.onCustomizedStateRootChange()"); HelixManager manager = changeContext.getManager(); Builder keyBuilder = new Builder(manager.getClusterName()); if (customizedStateTypes.isEmpty()) { customizedStateTypes = manager.getHelixDataAccessor() .getChildNames(keyBuilder.customizedStatesRoot(instanceName)); } synchronized (_lastSeenCustomizedStateTypesMap) { Map<String, Set<String>> lastSeenCustomizedStateTypesMap = _lastSeenCustomizedStateTypesMap.get(); <START> Set<String> lastSeenCustomizedStateTypes = new HashSet<>(); <END> if (lastSeenCustomizedStateTypesMap != null && lastSeenCustomizedStateTypesMap .containsKey(instanceName)) { lastSeenCustomizedStateTypes = lastSeenCustomizedStateTypesMap.get(instanceName); } for (String customizedState : customizedStateTypes) { try { if (lastSeenCustomizedStateTypes == null || !lastSeenCustomizedStateTypes .contains(customizedState)) { manager.addCustomizedStateChangeListener(this, instanceName, customizedState); logger.info( manager.getInstanceName() + " added customized state listener for " + instanceName + ", listener: " + this); } } catch (Exception e) { logger.error("Fail to add customized state listener for instance: " + instanceName, e); } } if (lastSeenCustomizedStateTypes != null) { for (String previousCustomizedState : lastSeenCustomizedStateTypes) { if (!customizedStateTypes.contains(previousCustomizedState)) { manager .removeListener(keyBuilder.customizedStates(instanceName, previousCustomizedState), this); } } } if (lastSeenCustomizedStateTypesMap == null) { Map<String, Set<String>> currentTypesMap = new HashMap<>(); currentTypesMap.put(instanceName, new HashSet<>(customizedStateTypes)); _lastSeenCustomizedStateTypesMap.set(currentTypesMap); } else { _lastSeenCustomizedStateTypesMap.get() .put(instanceName, new HashSet<>(customizedStateTypes)); } } }</code><technical_language>Collections.emtpySet()</technical_language>

Target:
public void onCustomizedStateRootChange(String instanceName, List<String> customizedStateTypes, NotificationContext changeContext) { logger.info("START: GenericClusterController.onCustomizedStateRootChange()"); HelixManager manager = changeContext.getManager(); Builder keyBuilder = new Builder(manager.getClusterName()); if (customizedStateTypes.isEmpty()) { customizedStateTypes = manager.getHelixDataAccessor() .getChildNames(keyBuilder.customizedStatesRoot(instanceName)); } synchronized (_lastSeenCustomizedStateTypesMapRef) { Map<String, Set<String>> lastSeenCustomizedStateTypesMap = _lastSeenCustomizedStateTypesMapRef.get(); if (null == lastSeenCustomizedStateTypesMap) { lastSeenCustomizedStateTypesMap = new HashMap(); _lastSeenCustomizedStateTypesMapRef.set(lastSeenCustomizedStateTypesMap); } if (!lastSeenCustomizedStateTypesMap.containsKey(instanceName)) { lastSeenCustomizedStateTypesMap.put(instanceName, Collections.emptySet()); } Set<String> lastSeenCustomizedStateTypes = lastSeenCustomizedStateTypesMap.get(instanceName); for (String customizedState : customizedStateTypes) { try { if (!lastSeenCustomizedStateTypes.contains(customizedState)) { manager.addCustomizedStateChangeListener(this, instanceName, customizedState); logger.info( manager.getInstanceName() + " added customized state listener for " + instanceName + ", listener: " + this); } } catch (Exception e) { logger.error("Fail to add customized state listener for instance: " + instanceName, e); } } for (String previousCustomizedState : lastSeenCustomizedStateTypes) { if (!customizedStateTypes.contains(previousCustomizedState)) { manager.removeListener(keyBuilder.customizedStates(instanceName, previousCustomizedState), this); } } lastSeenCustomizedStateTypes.clear(); lastSeenCustomizedStateTypes.addAll(customizedStateTypes); } }