GUACAMOLE-96: Do not rely on Map.remove(key, value) which is specific to Java 8.

This commit is contained in:
Michael Jumper
2018-02-01 13:01:43 -08:00
parent 1c012f4ed0
commit 3a90dbbd00

View File

@@ -83,10 +83,22 @@ public class ArbitraryAttributeMap extends HashMap<String, String> {
if (!(o instanceof ArbitraryAttributeModel)) if (!(o instanceof ArbitraryAttributeModel))
return false; return false;
// The attribute should be removed only if the value matches // Remove only if key is actually present
ArbitraryAttributeModel model = (ArbitraryAttributeModel) o; ArbitraryAttributeModel model = (ArbitraryAttributeModel) o;
return ArbitraryAttributeMap.this.remove(model.getName(), if (!ArbitraryAttributeMap.this.containsKey(model.getName()))
model.getValue()); return false;
// The attribute should be removed only if the value matches
String currentValue = ArbitraryAttributeMap.this.get(model.getName());
if (currentValue == null) {
if (model.getValue() != null)
return false;
}
else if (!currentValue.equals(model.getValue()))
return false;
ArbitraryAttributeMap.this.remove(model.getName());
return true;
} }