Skip to content

Commit 900b36f

Browse files
marschallfmbenhassine
authored andcommitted
Use ExecutionContext map constructor
Use ExecutionContext map constructor to simplify ExecutionContextRowMapper.mapRow. Issue #3985
1 parent 097891f commit 900b36f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2018 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -313,7 +313,6 @@ private class ExecutionContextRowMapper implements RowMapper<ExecutionContext> {
313313

314314
@Override
315315
public ExecutionContext mapRow(ResultSet rs, int i) throws SQLException {
316-
ExecutionContext executionContext = new ExecutionContext();
317316
String serializedContext = rs.getString("SERIALIZED_CONTEXT");
318317
if (serializedContext == null) {
319318
serializedContext = rs.getString("SHORT_CONTEXT");
@@ -327,10 +326,7 @@ public ExecutionContext mapRow(ResultSet rs, int i) throws SQLException {
327326
catch (IOException ioe) {
328327
throw new IllegalArgumentException("Unable to deserialize the execution context", ioe);
329328
}
330-
for (Map.Entry<String, Object> entry : map.entrySet()) {
331-
executionContext.put(entry.getKey(), entry.getValue());
332-
}
333-
return executionContext;
329+
return new ExecutionContext(map);
334330
}
335331
}
336332

0 commit comments

Comments
 (0)