Merge pull request #137 from spring-projects/spring-batch-excel-to-batch-51

Upgrade to Spring Batch 5.1
This commit is contained in:
Marten Deinum
2024-08-07 13:01:02 +02:00
committed by GitHub
6 changed files with 16 additions and 17 deletions

View File

@@ -42,16 +42,16 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>17</java.version>
<spring.batch.version>4.3.9</spring.batch.version>
<poi.version>4.1.2</poi.version>
<spring.batch.version>5.1.2</spring.batch.version>
<poi.version>5.3.0</poi.version>
<!-- Test Dependencies -->
<assertj.version>3.18.1</assertj.version>
<junit.jupiter.version>5.8.2</junit.jupiter.version>
<assertj.version>3.26.3</assertj.version>
<junit.jupiter.version>5.10.2</junit.jupiter.version>
<slf4j.version>1.7.36</slf4j.version>
<mockito.version>3.12.4</mockito.version>
<mockito.version>5.12.0</mockito.version>
</properties>
<developers>

View File

@@ -132,7 +132,7 @@ public abstract class AbstractExcelItemReader<T> extends AbstractItemCountingIte
*/
@Override
protected void jumpToItem(final int itemIndex) {
RowMapper<T> current = this.rowMapper;
var current = this.rowMapper;
this.rowMapper = (rs) -> null;
try {
for (int i = 0; i < itemIndex; i++) {
@@ -145,8 +145,8 @@ public abstract class AbstractExcelItemReader<T> extends AbstractItemCountingIte
}
private boolean isInvalidValidRow(RowSet rs) {
for (String str : rs.getCurrentRow()) {
if (str.length() > 0) {
for (var str : rs.getCurrentRow()) {
if (!str.isEmpty()) {
return false;
}
}
@@ -220,7 +220,7 @@ public abstract class AbstractExcelItemReader<T> extends AbstractItemCountingIte
this.resource = resource;
}
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.notNull(this.rowMapper, "RowMapper must be set");
if (this.datesAsIso) {
this.dataFormatter = (this.userLocale != null) ? new IsoFormattingDateDataFormatter(this.userLocale) : new IsoFormattingDateDataFormatter();

View File

@@ -140,11 +140,10 @@ public class BeanWrapperRowMapper<T> extends DefaultPropertyEditorRegistrar
/**
* Check that precisely one of type or prototype bean name is specified.
* @throws IllegalStateException if neither is set or both properties are set.
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.state(this.name != null || this.type != null, "Either name or type must be provided.");
Assert.state(this.name == null || this.type == null, "Both name and type cannot be specified together.");
}

View File

@@ -29,7 +29,7 @@ import org.springframework.batch.extensions.excel.support.rowset.RowSet;
public class PassThroughRowMapper implements RowMapper<String[]> {
@Override
public String[] mapRow(final RowSet rs) throws Exception {
public String[] mapRow(final RowSet rs) {
return rs.getCurrentRow();
}

View File

@@ -100,10 +100,10 @@ final class PropertyMatches {
* @return the distance value
*/
private int calculateStringDistance(String s1, String s2) {
if (s1.length() == 0) {
if (s1.isEmpty()) {
return s2.length();
}
if (s2.length() == 0) {
if (s2.isEmpty()) {
return s1.length();
}
int[][] d = new int[s1.length() + 1][s2.length() + 1];

View File

@@ -50,12 +50,12 @@ public class MockExcelItemReader<T> extends AbstractExcelItemReader<T> {
}
@Override
protected void openExcelFile(Resource resource, String password) throws Exception {
protected void openExcelFile(Resource resource, String password) {
}
@Override
protected void doClose() throws Exception {
protected void doClose() {
this.sheets.clear();
}