Skip to content

Commit

Permalink
[formtypes] Log warning on inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowdalic committed Feb 25, 2021
1 parent 97a5cc7 commit a71d16a
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -18,6 +18,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlUtil;
Expand All @@ -27,6 +28,8 @@

public class FormFieldRegistry {

private static final Logger LOGGER = Logger.getLogger(FormFieldRegistry.class.getName());

private static final Map<String, Map<String, FormField.Type>> REGISTRY = new HashMap<>();

private static final Map<String, String> FIELD_NAME_TO_FORM_TYPE = new HashMap<>();
Expand Down Expand Up @@ -69,7 +72,10 @@ public static synchronized void register(String formType, String fieldName, Form
throw new IllegalArgumentException();
}
}
fieldNameToType.put(fieldName, type);
FormField.Type previousType = fieldNameToType.put(fieldName, type);
if (previousType != null && type != previousType) {
LOGGER.warning("Form field registry inconsitency detected: Registered field '" + fieldName + "' of type " + type + " but previous type was " + previousType);
}

FIELD_NAME_TO_FORM_TYPE.put(fieldName, formType);
}
Expand Down

0 comments on commit a71d16a

Please sign in to comment.