Skip to content

Commit 39ffa4e

Browse files
authored
Merge pull request #137 from spring-projects/spring-batch-excel-to-batch-51
Upgrade to Spring Batch 5.1
2 parents c871dca + 61b3220 commit 39ffa4e

File tree

6 files changed

+16
-17
lines changed

6 files changed

+16
-17
lines changed

spring-batch-excel/pom.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4343
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4444

45-
<java.version>1.8</java.version>
45+
<java.version>17</java.version>
4646

47-
<spring.batch.version>4.3.9</spring.batch.version>
48-
<poi.version>4.1.2</poi.version>
47+
<spring.batch.version>5.1.2</spring.batch.version>
48+
<poi.version>5.3.0</poi.version>
4949

5050
<!-- Test Dependencies -->
51-
<assertj.version>3.18.1</assertj.version>
52-
<junit.jupiter.version>5.8.2</junit.jupiter.version>
51+
<assertj.version>3.26.3</assertj.version>
52+
<junit.jupiter.version>5.10.2</junit.jupiter.version>
5353
<slf4j.version>1.7.36</slf4j.version>
54-
<mockito.version>3.12.4</mockito.version>
54+
<mockito.version>5.12.0</mockito.version>
5555
</properties>
5656

5757
<developers>

spring-batch-excel/src/main/java/org/springframework/batch/extensions/excel/AbstractExcelItemReader.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected T doRead() {
132132
*/
133133
@Override
134134
protected void jumpToItem(final int itemIndex) {
135-
RowMapper<T> current = this.rowMapper;
135+
var current = this.rowMapper;
136136
this.rowMapper = (rs) -> null;
137137
try {
138138
for (int i = 0; i < itemIndex; i++) {
@@ -145,8 +145,8 @@ protected void jumpToItem(final int itemIndex) {
145145
}
146146

147147
private boolean isInvalidValidRow(RowSet rs) {
148-
for (String str : rs.getCurrentRow()) {
149-
if (str.length() > 0) {
148+
for (var str : rs.getCurrentRow()) {
149+
if (!str.isEmpty()) {
150150
return false;
151151
}
152152
}
@@ -220,7 +220,7 @@ public void setResource(final Resource resource) {
220220
this.resource = resource;
221221
}
222222

223-
public void afterPropertiesSet() throws Exception {
223+
public void afterPropertiesSet() {
224224
Assert.notNull(this.rowMapper, "RowMapper must be set");
225225
if (this.datesAsIso) {
226226
this.dataFormatter = (this.userLocale != null) ? new IsoFormattingDateDataFormatter(this.userLocale) : new IsoFormattingDateDataFormatter();

spring-batch-excel/src/main/java/org/springframework/batch/extensions/excel/mapping/BeanWrapperRowMapper.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,10 @@ public void setTargetType(Class<? extends T> type) {
140140

141141
/**
142142
* Check that precisely one of type or prototype bean name is specified.
143-
* @throws IllegalStateException if neither is set or both properties are set.
144143
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
145144
*/
146145
@Override
147-
public void afterPropertiesSet() throws Exception {
146+
public void afterPropertiesSet() {
148147
Assert.state(this.name != null || this.type != null, "Either name or type must be provided.");
149148
Assert.state(this.name == null || this.type == null, "Both name and type cannot be specified together.");
150149
}

spring-batch-excel/src/main/java/org/springframework/batch/extensions/excel/mapping/PassThroughRowMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
public class PassThroughRowMapper implements RowMapper<String[]> {
3030

3131
@Override
32-
public String[] mapRow(final RowSet rs) throws Exception {
32+
public String[] mapRow(final RowSet rs) {
3333
return rs.getCurrentRow();
3434
}
3535

spring-batch-excel/src/main/java/org/springframework/batch/extensions/excel/mapping/PropertyMatches.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ private String[] calculateMatches(PropertyDescriptor[] propertyDescriptors, int
100100
* @return the distance value
101101
*/
102102
private int calculateStringDistance(String s1, String s2) {
103-
if (s1.length() == 0) {
103+
if (s1.isEmpty()) {
104104
return s2.length();
105105
}
106-
if (s2.length() == 0) {
106+
if (s2.isEmpty()) {
107107
return s1.length();
108108
}
109109
int[][] d = new int[s1.length() + 1][s2.length() + 1];

spring-batch-excel/src/test/java/org/springframework/batch/extensions/excel/MockExcelItemReader.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ protected int getNumberOfSheets() {
5050
}
5151

5252
@Override
53-
protected void openExcelFile(Resource resource, String password) throws Exception {
53+
protected void openExcelFile(Resource resource, String password) {
5454

5555
}
5656

5757
@Override
58-
protected void doClose() throws Exception {
58+
protected void doClose() {
5959
this.sheets.clear();
6060
}
6161

0 commit comments

Comments
 (0)