Add default component name in constructor of AvroItemReader

Issue #4285
This commit is contained in:
drow724
2023-01-17 11:27:00 +09:00
committed by Mahmoud Ben Hassine
parent 2cc0be4a0c
commit 89e76164af

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import org.springframework.batch.item.support.AbstractItemCountingItemStreamItem
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* An {@link ItemReader} that deserializes data from a {@link Resource} containing
@@ -42,6 +43,7 @@ import org.springframework.util.Assert;
*
* @author David Turanski
* @author Mahmoud Ben Hassine
* @author Song JaeGeun
* @since 4.2
*/
public class AvroItemReader<T> extends AbstractItemCountingItemStreamItemReader<T> {
@@ -61,6 +63,8 @@ public class AvroItemReader<T> extends AbstractItemCountingItemStreamItemReader<
* @param clazz the data type to be deserialized.
*/
public AvroItemReader(Resource resource, Class<T> clazz) {
setName(ClassUtils.getShortName(AvroItemReader.class));
Assert.notNull(resource, "'resource' is required.");
Assert.notNull(clazz, "'class' is required.");
@@ -78,6 +82,8 @@ public class AvroItemReader<T> extends AbstractItemCountingItemStreamItemReader<
* @param schema the {@link Resource} containing the Avro schema.
*/
public AvroItemReader(Resource data, Resource schema) {
setName(ClassUtils.getShortName(AvroItemReader.class));
Assert.notNull(data, "'data' is required.");
Assert.state(data.exists(), "'data' " + data.getFilename() + " does not exist.");
Assert.notNull(schema, "'schema' is required");