Polish contribution
This commit is contained in:
@@ -73,6 +73,10 @@ public class JsonItemReader<T> extends AbstractItemCountingItemStreamItemReader<
|
||||
this.jsonObjectReader = jsonObjectReader;
|
||||
setExecutionContextName(ClassUtils.getShortName(JsonItemReader.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link JsonItemReader} instance.
|
||||
*/
|
||||
public JsonItemReader(){
|
||||
setExecutionContextName(ClassUtils.getShortName(JsonItemReader.class));
|
||||
}
|
||||
@@ -108,6 +112,8 @@ public class JsonItemReader<T> extends AbstractItemCountingItemStreamItemReader<
|
||||
|
||||
@Override
|
||||
protected void doOpen() throws Exception {
|
||||
Assert.notNull(this.resource, "The resource must not be null.");
|
||||
Assert.notNull(this.jsonObjectReader, "The json object reader must not be null.");
|
||||
if (!this.resource.exists()) {
|
||||
if (this.strict) {
|
||||
throw new IllegalStateException("Input resource must exist (reader is in 'strict' mode)");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Copyright 2018-2020 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.
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.batch.item.json.builder;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.batch.item.json.JsonItemReader;
|
||||
import org.springframework.batch.item.json.JsonObjectReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -32,6 +35,8 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class JsonItemReaderBuilder<T> {
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private JsonObjectReader<T> jsonObjectReader;
|
||||
|
||||
private Resource resource;
|
||||
@@ -144,6 +149,11 @@ public class JsonItemReaderBuilder<T> {
|
||||
Assert.state(StringUtils.hasText(this.name), "A name is required when saveState is set to true.");
|
||||
}
|
||||
|
||||
if (this.resource == null) {
|
||||
logger.debug("The resource is null. This is only a valid scenario when " +
|
||||
"injecting it later as in when using the MultiResourceItemReader");
|
||||
}
|
||||
|
||||
JsonItemReader<T> reader = new JsonItemReader<>();
|
||||
reader.setResource(this.resource);
|
||||
reader.setJsonObjectReader(this.jsonObjectReader);
|
||||
|
||||
Reference in New Issue
Block a user