1717
1818package org .openqa .selenium .json ;
1919
20+ import static java .util .Objects .requireNonNull ;
21+
2022import java .lang .reflect .ParameterizedType ;
2123import java .lang .reflect .Type ;
2224import java .util .function .BiConsumer ;
2325import java .util .function .BiFunction ;
2426import java .util .function .Function ;
2527import java .util .function .Supplier ;
28+ import org .jspecify .annotations .Nullable ;
2629
2730class MapCoercer <T , I extends T > extends TypeCoercer <T > {
2831
2932 private final Class <T > stereotype ;
3033 private final JsonTypeCoercer coercer ;
3134 private final Supplier <I > supplier ;
32- private final Function <I , BiConsumer <Object , Object >> consumerFactory ;
35+ private final Function <I , BiConsumer <Object , @ Nullable Object >> consumerFactory ;
3336
3437 public MapCoercer (
3538 Class <T > stereotype ,
3639 JsonTypeCoercer coercer ,
3740 Supplier <I > supplier ,
38- Function <I , BiConsumer <Object , Object >> consumerFactory ) {
41+ Function <I , BiConsumer <Object , @ Nullable Object >> consumerFactory ) {
3942 this .stereotype = stereotype ;
4043 this .coercer = coercer ;
4144 this .supplier = supplier ;
@@ -66,7 +69,7 @@ public BiFunction<JsonInput, PropertySetting, T> apply(Type type) {
6669 return (jsonInput , setting ) -> {
6770 jsonInput .beginObject ();
6871 I toReturn = supplier .get ();
69- BiConsumer <Object , Object > consumer = consumerFactory .apply (toReturn );
72+ BiConsumer <Object , @ Nullable Object > consumer = consumerFactory .apply (toReturn );
7073 // JSON should always have a string key, so we can take the fastpath
7174 boolean stringKey = String .class .equals (keyType );
7275
@@ -76,7 +79,7 @@ public BiFunction<JsonInput, PropertySetting, T> apply(Type type) {
7679 if (stringKey ) {
7780 key = jsonInput .nextName ();
7881 } else {
79- key = coercer .coerce (jsonInput , keyType , setting );
82+ key = requireNonNull ( coercer .coerce (jsonInput , keyType , setting ) );
8083 }
8184 Object value = coercer .coerce (jsonInput , valueType , setting );
8285
0 commit comments