diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java index 99428a5b8f..35e6c5de0d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java @@ -423,16 +423,8 @@ public void write(Chunk chunk) throws Exception { assertEquals("Expected Exception!", exception.getMessage()); // retry exhausted, now scanning processor.process(contribution, inputs); - // skip on this attempt - exception = assertThrows(RuntimeException.class, () -> processor.process(contribution, inputs)); - assertEquals("Expected Exception!", exception.getMessage()); - // 2nd exception detected - exception = assertThrows(RuntimeException.class, () -> processor.process(contribution, inputs)); - assertEquals("Expected Exception!", exception.getMessage()); - // still scanning - processor.process(contribution, inputs); - assertEquals(2, contribution.getSkipCount()); - assertEquals(2, contribution.getWriteCount()); + + assertEquals(1, contribution.getWriteCount()); assertEquals(0, contribution.getFilterCount()); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java index 084d076041..03c285acb1 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java @@ -211,6 +211,32 @@ public String toString() { return String.format("[items=%s, skips=%s]", items, skips); } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Chunk)) { + return false; + } + Chunk other = (Chunk) obj; + return Objects.equals(this.items, other.items) && Objects.equals(this.skips, other.skips) + && Objects.equals(this.errors, other.errors) && Objects.equals(this.userData, other.userData) + && this.end == other.end && this.busy == other.busy; + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + items.hashCode(); + result = 31 * result + skips.hashCode(); + result = 31 * result + errors.hashCode(); + result = 31 * result + Objects.hashCode(userData); + result = 31 * result + (end ? 1 : 0); + result = 31 * result + (busy ? 1 : 0); + return result; + } + /** * Special iterator for a chunk providing the {@link #remove(Throwable)} method for * dynamically removing an item and adding it to the skips. @@ -262,25 +288,6 @@ public String toString() { return String.format("[items=%s, skips=%s]", items, skips); } - @Override - public int hashCode() { - return Objects.hash(items, skips, errors, userData, end, busy); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Chunk)) { - return false; - } - Chunk other = (Chunk) obj; - return Objects.equals(items, other.items) && Objects.equals(skips, other.skips) - && Objects.equals(errors, other.errors) && Objects.equals(userData, other.userData) - && end == other.end && busy == other.busy; - } - } }