Method clearAttributesWithExclude of class DynamicManager cannot work.
The method clearAttributesWithExclude
of class DynamicManager
cannot work. The method attempts to modify the dynamicAttributes
map while iterating over it. As only the keys are usefull in this context, a local copy should be made. The proper code would be:
public void clearAttributesWithExclude(final String... exclude) throws DevFailed {
final String[] toExclude = new String[exclude.length];
for (int i = 0; i < toExclude.length; i++) {
toExclude[i] = exclude[i].toLowerCase(Locale.ENGLISH);
}
List<String> attributes = new ArrayList<>(dynamicAttributes.keySet());
for (final String attributeName : attributes) {
if (!ArrayUtils.contains(toExclude, attributeName)) {
removeAttribute(attributeName);
}
}
}