Class UnknownFieldsWarning
java.lang.Object
org.openqa.selenium.json.UnknownFieldsWarning
Shared "log, don't silently drop" behavior for a JSON object carrying a key the receiving Java
type doesn't declare.
ConstructorCoercer calls this for any type annotated WarnOnUnknownFields; a generated type with a custom deserializer that bypasses
ConstructorCoercer entirely (e.g. one with a reserved-word field — see BiDiGenerator's
appendFromJson) calls it directly, so both paths report the same way instead of one of them
silently dropping unrecognized keys.
Logs under ConstructorCoercer's own category, not this class's: the warning predates
this extraction (it originally lived inline in ConstructorCoercer), and a generated type's custom
deserializer stands in for ConstructorCoercer here rather than being a distinct source — see the
call site in BiDiGenerator's appendFromJson. Keeping one category means anyone who already
configured logging for ConstructorCoercer keeps controlling these warnings after this
split, instead of that configuration silently going stale.
-
Method Summary
-
Method Details
-
warnOnUnknownFields
public static void warnOnUnknownFields(Class<?> declaringClass, Set<String> knownKeys, Map<String, ?> received) Logs a bounded, sanitized warning ifreceivedcarries any key absent fromknownKeys. Gated onisLoggableso a disabled WARNING level skips even scanning for unknown keys, not just building the message — that scan scales with an attacker-controlled payload size.- Parameters:
declaringClass- the type the caller is deserializing into, named in the log messageknownKeys- every keydeclaringClassactually declaresreceived- the raw JSON object being deserialized
-