mirror of https://github.com/apache/druid.git
Add check for required avroBytesDecoder property that otherwise causes NPE. (#14177)
This commit is contained in:
parent
ac7181bbda
commit
954f3917ef
|
@ -25,6 +25,7 @@ import org.apache.druid.data.input.InputEntity;
|
|||
import org.apache.druid.data.input.InputEntityReader;
|
||||
import org.apache.druid.data.input.InputRowSchema;
|
||||
import org.apache.druid.data.input.impl.NestedInputFormat;
|
||||
import org.apache.druid.java.util.common.IAE;
|
||||
import org.apache.druid.java.util.common.parsers.JSONPathSpec;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -48,6 +49,9 @@ public class AvroStreamInputFormat extends NestedInputFormat
|
|||
)
|
||||
{
|
||||
super(flattenSpec);
|
||||
if (avroBytesDecoder == null) {
|
||||
throw new IAE("avroBytesDecoder is required to decode Avro records");
|
||||
}
|
||||
this.avroBytesDecoder = avroBytesDecoder;
|
||||
this.binaryAsString = binaryAsString != null && binaryAsString;
|
||||
this.extractUnionsByType = extractUnionsByType != null && extractUnionsByType;
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.druid.data.input.impl.TimestampSpec;
|
|||
import org.apache.druid.data.input.schemarepo.Avro1124RESTRepositoryClientWrapper;
|
||||
import org.apache.druid.data.input.schemarepo.Avro1124SubjectAndIdConverter;
|
||||
import org.apache.druid.jackson.DefaultObjectMapper;
|
||||
import org.apache.druid.java.util.common.IAE;
|
||||
import org.apache.druid.java.util.common.parsers.JSONPathFieldSpec;
|
||||
import org.apache.druid.java.util.common.parsers.JSONPathFieldType;
|
||||
import org.apache.druid.java.util.common.parsers.JSONPathSpec;
|
||||
|
@ -202,6 +203,21 @@ public class AvroStreamInputFormatTest extends InitializedNullHandlingTest
|
|||
Assert.assertEquals(inputFormat, inputFormat2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingAvroBytesDecoderRaisesIAE()
|
||||
{
|
||||
Assert.assertThrows(
|
||||
"avroBytesDecoder is required to decode Avro records",
|
||||
IAE.class,
|
||||
() -> new AvroStreamInputFormat(
|
||||
flattenSpec,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse() throws SchemaValidationException, IOException
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue