Description
If you have a union with a default of null, the code in RecordBuilderBase.defaultValue will cause an NPE in ConcurrentHashMap, since it is trying to add a null to the map.
Sample union:
record Sample { union{null, string} value = null; }
Code:
// If not cached, get the default Java value by encoding the default JSON // value and then decoding it: if (defaultValue == null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); encoder = EncoderFactory.get().binaryEncoder(baos, encoder); ResolvingGrammarGenerator.encode(encoder, field.schema(), defaultJsonValue); encoder.flush(); decoder = DecoderFactory.get().binaryDecoder(baos.toByteArray(), decoder); defaultValue = new GenericDatumReader(field.schema()).read(null, decoder); defaultSchemaValues.putIfAbsent(field.pos(), defaultValue); // <-- NPE from here }