Use diamond operator where appropriate

This commit is contained in:
Mahmoud Ben Hassine
2023-06-05 13:48:31 +02:00
parent 0dc5b63469
commit 92159cbc2b
105 changed files with 411 additions and 403 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -26,6 +26,7 @@ import org.springframework.batch.core.ItemReadListener;
/**
* @author Lucas Ward
* @author Will Schipp
* @author Mahmoud Ben Hassine
*
*/
class CompositeItemReadListenerTests {
@@ -66,7 +67,7 @@ class CompositeItemReadListenerTests {
@Test
void testSetListeners() {
compositeListener.setListeners(new ArrayList<ItemReadListener<? super Object>>() {
compositeListener.setListeners(new ArrayList<>() {
{
add(listener);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -69,7 +69,7 @@ class CompositeItemWriteListenerTests {
@Test
void testSetListeners() {
compositeListener.setListeners(new ArrayList<ItemWriteListener<? super Object>>() {
compositeListener.setListeners(new ArrayList<>() {
{
add(listener);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -345,7 +345,7 @@ class MulticasterBatchListenerTests {
*/
@Test
void testOnSkipInRead() {
multicast.register(new SkipListener<Object, Object>() {
multicast.register(new SkipListener<>() {
@Override
public void onSkipInRead(Throwable t) {
count++;
@@ -362,7 +362,7 @@ class MulticasterBatchListenerTests {
*/
@Test
void testOnSkipInReadFails() {
multicast.register(new SkipListener<Object, Object>() {
multicast.register(new SkipListener<>() {
@Override
public void onSkipInRead(Throwable t) {
count++;
@@ -383,7 +383,7 @@ class MulticasterBatchListenerTests {
*/
@Test
void testOnSkipInWrite() {
multicast.register(new SkipListener<Object, Object>() {
multicast.register(new SkipListener<>() {
@Override
public void onSkipInWrite(Object item, Throwable t) {
count++;
@@ -400,7 +400,7 @@ class MulticasterBatchListenerTests {
*/
@Test
void testOnSkipInWriteFails() {
multicast.register(new SkipListener<Object, Object>() {
multicast.register(new SkipListener<>() {
@Override
public void onSkipInWrite(Object item, Throwable t) {
count++;
@@ -421,7 +421,7 @@ class MulticasterBatchListenerTests {
*/
@Test
void testOnSkipInProcess() {
multicast.register(new SkipListener<Object, Object>() {
multicast.register(new SkipListener<>() {
@Override
public void onSkipInProcess(Object item, Throwable t) {
count++;
@@ -438,7 +438,7 @@ class MulticasterBatchListenerTests {
*/
@Test
void testOnSkipInProcessFails() {
multicast.register(new SkipListener<Object, Object>() {
multicast.register(new SkipListener<>() {
@Override
public void onSkipInProcess(Object item, Throwable t) {
count++;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2023 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.
@@ -91,7 +91,7 @@ public class AsyncJobScopeIntegrationTests implements BeanFactoryAware {
for (int i = 0; i < 12; i++) {
final String value = "foo" + i;
final Long id = 123L + i;
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
FutureTask<String> task = new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
JobExecution jobExecution = new JobExecution(id);
@@ -131,7 +131,7 @@ public class AsyncJobScopeIntegrationTests implements BeanFactoryAware {
for (int i = 0; i < 12; i++) {
final String value = "foo" + i;
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
FutureTask<String> task = new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
ExecutionContext executionContext = jobExecution.getExecutionContext();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-2023 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.
@@ -92,7 +92,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
for (int i = 0; i < 12; i++) {
final String value = "foo" + i;
final Long id = 123L + i;
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
FutureTask<String> task = new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
StepExecution stepExecution = new StepExecution(value, new JobExecution(0L), id);
@@ -132,7 +132,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
for (int i = 0; i < 12; i++) {
final String value = "foo" + i;
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
FutureTask<String> task = new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
ExecutionContext executionContext = stepExecution.getExecutionContext();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -38,6 +38,7 @@ import org.springframework.context.support.StaticApplicationContext;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
class StepScopeTests {
@@ -63,7 +64,7 @@ class StepScopeTests {
void testGetWithNoContext() {
final String foo = "bar";
StepSynchronizationManager.close();
assertThrows(IllegalStateException.class, () -> scope.get("foo", new ObjectFactory<Object>() {
assertThrows(IllegalStateException.class, () -> scope.get("foo", new ObjectFactory<>() {
@Override
public Object getObject() throws BeansException {
return foo;
@@ -74,7 +75,7 @@ class StepScopeTests {
@Test
void testGetWithNothingAlreadyThere() {
final String foo = "bar";
Object value = scope.get("foo", new ObjectFactory<Object>() {
Object value = scope.get("foo", new ObjectFactory<>() {
@Override
public Object getObject() throws BeansException {
return foo;
@@ -87,7 +88,7 @@ class StepScopeTests {
@Test
void testGetWithSomethingAlreadyThere() {
context.setAttribute("foo", "bar");
Object value = scope.get("foo", new ObjectFactory<Object>() {
Object value = scope.get("foo", new ObjectFactory<>() {
@Override
public Object getObject() throws BeansException {
return null;
@@ -101,7 +102,7 @@ class StepScopeTests {
void testGetWithSomethingAlreadyInParentContext() {
context.setAttribute("foo", "bar");
StepContext context = StepSynchronizationManager.register(new StepExecution("bar", new JobExecution(0L)));
Object value = scope.get("foo", new ObjectFactory<Object>() {
Object value = scope.get("foo", new ObjectFactory<>() {
@Override
public Object getObject() throws BeansException {
return "spam";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2023 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.
@@ -75,7 +75,7 @@ class JobSynchronizationManagerTests {
void testMultithreaded() throws Exception {
JobContext context = JobSynchronizationManager.register(jobExecution);
ExecutorService executorService = Executors.newFixedThreadPool(2);
FutureTask<JobContext> task = new FutureTask<>(new Callable<JobContext>() {
FutureTask<JobContext> task = new FutureTask<>(new Callable<>() {
@Override
public JobContext call() throws Exception {
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2023 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.
@@ -71,7 +71,7 @@ class StepSynchronizationManagerTests {
void testMultithreaded() throws Exception {
StepContext context = StepSynchronizationManager.register(stepExecution);
ExecutorService executorService = Executors.newFixedThreadPool(2);
FutureTask<StepContext> task = new FutureTask<>(new Callable<StepContext>() {
FutureTask<StepContext> task = new FutureTask<>(new Callable<>() {
@Override
public StepContext call() throws Exception {
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2023 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.
@@ -144,7 +144,7 @@ class RegisterMultiListenerTests {
@Bean
public ItemReader<String> reader() {
return new ItemReader<String>() {
return new ItemReader<>() {
private int count = 0;
@@ -167,7 +167,7 @@ class RegisterMultiListenerTests {
@Bean
public ItemWriter<String> writer() {
return new ItemWriter<String>() {
return new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-2023 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.
@@ -70,7 +70,7 @@ class BatchRetryTemplateTests {
BatchRetryTemplate template = new BatchRetryTemplate();
RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
RetryCallback<String[], Exception> retryCallback = new RetryCallback<>() {
@Override
public String[] doWithRetry(RetryContext context) throws Exception {
assertEquals(count, context.getRetryCount());
@@ -97,7 +97,7 @@ class BatchRetryTemplateTests {
template.setRetryPolicy(new SimpleRetryPolicy(1,
Collections.<Class<? extends Throwable>, Boolean>singletonMap(Exception.class, true)));
RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
RetryCallback<String[], Exception> retryCallback = new RetryCallback<>() {
@Override
public String[] doWithRetry(RetryContext context) throws Exception {
if (count++ < 2) {
@@ -123,7 +123,7 @@ class BatchRetryTemplateTests {
template.setRetryPolicy(new SimpleRetryPolicy(1,
Collections.<Class<? extends Throwable>, Boolean>singletonMap(Exception.class, true)));
RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
RetryCallback<String[], Exception> retryCallback = new RetryCallback<>() {
@Override
public String[] doWithRetry(RetryContext context) throws Exception {
if (count++ < 1) {
@@ -166,7 +166,7 @@ class BatchRetryTemplateTests {
template.setRetryPolicy(new SimpleRetryPolicy(1,
Collections.<Class<? extends Throwable>, Boolean>singletonMap(Exception.class, true)));
RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
RetryCallback<String[], Exception> retryCallback = new RetryCallback<>() {
@Override
public String[] doWithRetry(RetryContext context) throws Exception {
if (count++ < 2) {
@@ -176,7 +176,7 @@ class BatchRetryTemplateTests {
}
};
RecoveryCallback<String[]> recoveryCallback = new RecoveryCallback<String[]>() {
RecoveryCallback<String[]> recoveryCallback = new RecoveryCallback<>() {
@Override
public String[] recover(RetryContext context) throws Exception {
List<String> recovered = new ArrayList<>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -40,7 +40,7 @@ class ChunkOrientedTaskletTests {
@Test
void testHandle() throws Exception {
ChunkOrientedTasklet<String> handler = new ChunkOrientedTasklet<>(new ChunkProvider<String>() {
ChunkOrientedTasklet<String> handler = new ChunkOrientedTasklet<>(new ChunkProvider<>() {
@Override
public Chunk<String> provide(StepContribution contribution) throws Exception {
contribution.incrementReadCount();
@@ -52,7 +52,7 @@ class ChunkOrientedTaskletTests {
@Override
public void postProcess(StepContribution contribution, Chunk<String> chunk) {
}
}, new ChunkProcessor<String>() {
}, new ChunkProcessor<>() {
@Override
public void process(StepContribution contribution, Chunk<String> chunk) {
contribution.incrementWriteCount(1);
@@ -68,7 +68,7 @@ class ChunkOrientedTaskletTests {
@Test
void testFail() {
ChunkOrientedTasklet<String> handler = new ChunkOrientedTasklet<>(new ChunkProvider<String>() {
ChunkOrientedTasklet<String> handler = new ChunkOrientedTasklet<>(new ChunkProvider<>() {
@Override
public Chunk<String> provide(StepContribution contribution) throws Exception {
throw new RuntimeException("Foo!");
@@ -77,7 +77,7 @@ class ChunkOrientedTaskletTests {
@Override
public void postProcess(StepContribution contribution, Chunk<String> chunk) {
}
}, new ChunkProcessor<String>() {
}, new ChunkProcessor<>() {
@Override
public void process(StepContribution contribution, Chunk<String> chunk) {
fail("Not expecting to get this far");
@@ -92,7 +92,7 @@ class ChunkOrientedTaskletTests {
@Test
void testExitCode() throws Exception {
ChunkOrientedTasklet<String> handler = new ChunkOrientedTasklet<>(new ChunkProvider<String>() {
ChunkOrientedTasklet<String> handler = new ChunkOrientedTasklet<>(new ChunkProvider<>() {
@Override
public Chunk<String> provide(StepContribution contribution) throws Exception {
contribution.incrementReadCount();
@@ -105,7 +105,7 @@ class ChunkOrientedTaskletTests {
@Override
public void postProcess(StepContribution contribution, Chunk<String> chunk) {
}
}, new ChunkProcessor<String>() {
}, new ChunkProcessor<>() {
@Override
public void process(StepContribution contribution, Chunk<String> chunk) {
contribution.incrementWriteCount(1);

View File

@@ -67,7 +67,7 @@ class FaultTolerantChunkProcessorTests {
@BeforeEach
void setUp() {
batchRetryTemplate = new BatchRetryTemplate();
processor = new FaultTolerantChunkProcessor<>(new PassThroughItemProcessor<>(), new ItemWriter<String>() {
processor = new FaultTolerantChunkProcessor<>(new PassThroughItemProcessor<>(), new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
@@ -88,7 +88,7 @@ class FaultTolerantChunkProcessorTests {
@Test
void testTransform() throws Exception {
processor.setItemProcessor(new ItemProcessor<String, String>() {
processor.setItemProcessor(new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
@@ -104,7 +104,7 @@ class FaultTolerantChunkProcessorTests {
@Test
void testFilterCountOnSkip() throws Exception {
processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemProcessor(new ItemProcessor<String, String>() {
processor.setItemProcessor(new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
@@ -130,7 +130,7 @@ class FaultTolerantChunkProcessorTests {
// BATCH-2663
void testFilterCountOnSkipInWriteWithoutRetry() throws Exception {
processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemProcessor(new ItemProcessor<String, String>() {
processor.setItemProcessor(new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
@@ -161,7 +161,7 @@ class FaultTolerantChunkProcessorTests {
retryPolicy.setMaxAttempts(3);
batchRetryTemplate.setRetryPolicy(retryPolicy);
processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemProcessor(new ItemProcessor<String, String>() {
processor.setItemProcessor(new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
@@ -194,7 +194,7 @@ class FaultTolerantChunkProcessorTests {
@Test
void testWriteSkipOnError() throws Exception {
processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemWriter(new ItemWriter<String>() {
processor.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
@@ -211,7 +211,7 @@ class FaultTolerantChunkProcessorTests {
@Test
void testWriteSkipOnException() throws Exception {
processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemWriter(new ItemWriter<String>() {
processor.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
@@ -233,7 +233,7 @@ class FaultTolerantChunkProcessorTests {
@Test
void testWriteSkipOnExceptionWithTrivialChunk() throws Exception {
processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemWriter(new ItemWriter<String>() {
processor.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
@@ -256,7 +256,7 @@ class FaultTolerantChunkProcessorTests {
@Test
void testTransformWithExceptionAndNoRollback() throws Exception {
processor.setItemProcessor(new ItemProcessor<String, String>() {
processor.setItemProcessor(new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
@@ -302,7 +302,7 @@ class FaultTolerantChunkProcessorTests {
@Test
void testAfterWriteAllPassedInRecovery() throws Exception {
Chunk<String> chunk = new Chunk<>(Arrays.asList("foo", "bar"));
processor = new FaultTolerantChunkProcessor<>(new PassThroughItemProcessor<>(), new ItemWriter<String>() {
processor = new FaultTolerantChunkProcessor<>(new PassThroughItemProcessor<>(), new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
// Fail if there is more than one item
@@ -349,7 +349,7 @@ class FaultTolerantChunkProcessorTests {
@Test
void testOnErrorInWriteAllItemsFail() throws Exception {
Chunk<String> chunk = new Chunk<>(Arrays.asList("foo", "bar"));
processor = new FaultTolerantChunkProcessor<>(new PassThroughItemProcessor<>(), new ItemWriter<String>() {
processor = new FaultTolerantChunkProcessor<>(new PassThroughItemProcessor<>(), new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> items) throws Exception {
// Always fail in writer
@@ -377,7 +377,7 @@ class FaultTolerantChunkProcessorTests {
retryPolicy.setMaxAttempts(2);
batchRetryTemplate.setRetryPolicy(retryPolicy);
processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemWriter(new ItemWriter<String>() {
processor.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
@@ -410,7 +410,7 @@ class FaultTolerantChunkProcessorTests {
retryPolicy.setMaxAttempts(2);
batchRetryTemplate.setRetryPolicy(retryPolicy);
processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemWriter(new ItemWriter<String>() {
processor.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
@@ -447,7 +447,7 @@ class FaultTolerantChunkProcessorTests {
batchRetryTemplate.setRetryPolicy(retryPolicy);
processor.setWriteSkipPolicy(new LimitCheckingItemSkipPolicy(1,
Collections.<Class<? extends Throwable>, Boolean>singletonMap(IllegalArgumentException.class, true)));
processor.setItemWriter(new ItemWriter<String>() {
processor.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
@@ -485,7 +485,7 @@ class FaultTolerantChunkProcessorTests {
final List<String> processedItems = new ArrayList<>();
processor.setProcessorTransactional(false);
processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemProcessor(new ItemProcessor<String, String>() {
processor.setItemProcessor(new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
@@ -521,7 +521,7 @@ class FaultTolerantChunkProcessorTests {
final List<String> processedItems = new ArrayList<>();
processor.setProcessorTransactional(false);
processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemProcessor(new ItemProcessor<String, String>() {
processor.setItemProcessor(new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2023 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.
@@ -54,7 +54,7 @@ class FaultTolerantChunkProviderTests {
@Test
void testProvideWithOverflow() throws Exception {
provider = new FaultTolerantChunkProvider<>(new ItemReader<String>() {
provider = new FaultTolerantChunkProvider<>(new ItemReader<>() {
@Nullable
@Override
public String read() throws Exception, UnexpectedInputException, ParseException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -90,7 +90,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
JobExecution jobExecution;
private ItemWriter<String> writer = new ItemWriter<String>() {
private ItemWriter<String> writer = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
processed.addAll(data.getItems());
@@ -153,7 +153,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
factory.setJobRepository(repository);
factory.setTransactionManager(new ResourcelessTransactionManager());
ItemWriter<Integer> failingWriter = new ItemWriter<Integer>() {
ItemWriter<Integer> failingWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends Integer> data) throws Exception {
int count = 0;
@@ -166,7 +166,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
}
};
ItemProcessor<String, Integer> processor = new ItemProcessor<String, Integer>() {
ItemProcessor<String, Integer> processor = new ItemProcessor<>() {
@Nullable
@Override
public Integer process(String item) throws Exception {
@@ -203,7 +203,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
void testProcessAllItemsWhenErrorInWriter() throws Exception {
final int RETRY_LIMIT = 3;
final List<String> ITEM_LIST = Arrays.asList("a", "b", "c");
ItemWriter<String> failingWriter = new ItemWriter<String>() {
ItemWriter<String> failingWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
int count = 0;
@@ -216,7 +216,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
}
};
ItemProcessor<String, String> processor = new ItemProcessor<String, String>() {
ItemProcessor<String, String> processor = new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
@@ -249,7 +249,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
@Test
void testNoItemsReprocessedWhenErrorInWriterAndProcessorNotTransactional() throws Exception {
ItemWriter<String> failingWriter = new ItemWriter<String>() {
ItemWriter<String> failingWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
int count = 0;
@@ -262,7 +262,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
}
};
ItemProcessor<String, String> processor = new ItemProcessor<String, String>() {
ItemProcessor<String, String> processor = new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
@@ -295,7 +295,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
@SuppressWarnings("unchecked")
@Test
void testSuccessfulRetryWithReadFailure() throws Exception {
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("a", "b", "c")) {
ItemReader<String> provider = new ListItemReader<>(Arrays.asList("a", "b", "c")) {
@Nullable
@Override
public String read() {
@@ -334,7 +334,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
factory.setSkipLimit(0);
factory.setCommitInterval(3);
AbstractItemCountingItemStreamItemReader<String> reader = new AbstractItemCountingItemStreamItemReader<String>() {
AbstractItemCountingItemStreamItemReader<String> reader = new AbstractItemCountingItemStreamItemReader<>() {
private ItemReader<String> reader;
@@ -359,7 +359,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
reader.setName("foo");
factory.setItemReader(reader);
factory.setStreams(new ItemStream[] { reader });
factory.setItemWriter(new ItemWriter<String>() {
factory.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (fail && chunk.getItems().contains("e")) {
@@ -396,7 +396,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
void testSkipAndRetry() throws Exception {
factory.setSkipLimit(2);
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("a", "b", "c", "d", "e", "f")) {
ItemReader<String> provider = new ListItemReader<>(Arrays.asList("a", "b", "c", "d", "e", "f")) {
@Nullable
@Override
public String read() {
@@ -434,7 +434,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
}
} });
factory.setSkipLimit(2);
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("a", "b", "c", "d", "e", "f")) {
ItemReader<String> provider = new ListItemReader<>(Arrays.asList("a", "b", "c", "d", "e", "f")) {
@Nullable
@Override
public String read() {
@@ -446,7 +446,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
}
};
ItemWriter<String> itemWriter = new ItemWriter<String>() {
ItemWriter<String> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
logger.debug("Write Called! Item: [" + chunk.getItems() + "]");
@@ -492,7 +492,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
}
} });
factory.setSkipLimit(2);
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("a", "b", "c", "d", "e", "f")) {
ItemReader<String> provider = new ListItemReader<>(Arrays.asList("a", "b", "c", "d", "e", "f")) {
@Nullable
@Override
public String read() {
@@ -504,7 +504,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
}
};
ItemWriter<String> itemWriter = new ItemWriter<String>() {
ItemWriter<String> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
logger.debug("Write Called! Item: [" + chunk + "]");
@@ -547,7 +547,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
factory.setRetryLimit(4);
factory.setSkipLimit(0);
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("b")) {
ItemReader<String> provider = new ListItemReader<>(Arrays.asList("b")) {
@Nullable
@Override
public String read() {
@@ -557,7 +557,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
return item;
}
};
ItemWriter<String> itemWriter = new ItemWriter<String>() {
ItemWriter<String> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
processed.addAll(chunk.getItems());
@@ -599,7 +599,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
factory.setRetryableExceptionClasses(getExceptionMap());
factory.setSkipLimit(1);
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("b")) {
ItemReader<String> provider = new ListItemReader<>(Arrays.asList("b")) {
@Nullable
@Override
public String read() {
@@ -609,7 +609,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
return item;
}
};
ItemWriter<String> itemWriter = new ItemWriter<String>() {
ItemWriter<String> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
processed.addAll(chunk.getItems());
@@ -646,7 +646,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
factory.setRetryPolicy(new SimpleRetryPolicy(4,
Collections.<Class<? extends Throwable>, Boolean>singletonMap(Exception.class, true)));
factory.setSkipLimit(0);
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("b")) {
ItemReader<String> provider = new ListItemReader<>(Arrays.asList("b")) {
@Nullable
@Override
public String read() {
@@ -656,7 +656,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
return item;
}
};
ItemWriter<String> itemWriter = new ItemWriter<String>() {
ItemWriter<String> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
processed.addAll(chunk.getItems());
@@ -694,7 +694,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
factory.setSkipLimit(10);
// set the cache limit stupidly low
factory.setRetryContextCache(new MapRetryContextCache(0));
ItemReader<String> provider = new ItemReader<String>() {
ItemReader<String> provider = new ItemReader<>() {
@Nullable
@Override
public String read() {
@@ -708,7 +708,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
return item;
}
};
ItemWriter<String> itemWriter = new ItemWriter<String>() {
ItemWriter<String> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
processed.addAll(chunk.getItems());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-2023 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.
@@ -451,7 +451,7 @@ public class FaultTolerantStepFactoryBeanTests {
map.put(SkippableRuntimeException.class, true);
map.put(FatalRuntimeException.class, false);
factory.setSkippableExceptionClasses(map);
factory.setItemWriter(new ItemWriter<String>() {
factory.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> items) {
throw new FatalRuntimeException("Ouch!");
@@ -860,7 +860,7 @@ public class FaultTolerantStepFactoryBeanTests {
void testItemStreamOpenedEvenWithTaskExecutor() throws Exception {
writer.setFailures("4");
ItemReader<String> reader = new AbstractItemStreamItemReader<String>() {
ItemReader<String> reader = new AbstractItemStreamItemReader<>() {
@Override
public void close() {
super.close();
@@ -899,7 +899,7 @@ public class FaultTolerantStepFactoryBeanTests {
void testNestedItemStreamOpened() throws Exception {
writer.setFailures("4");
ItemStreamReader<String> reader = new ItemStreamReader<String>() {
ItemStreamReader<String> reader = new ItemStreamReader<>() {
@Override
public void close() throws ItemStreamException {
}
@@ -919,7 +919,7 @@ public class FaultTolerantStepFactoryBeanTests {
}
};
ItemStreamReader<String> stream = new ItemStreamReader<String>() {
ItemStreamReader<String> stream = new ItemStreamReader<>() {
@Override
public void close() throws ItemStreamException {
closed = true;
@@ -961,7 +961,7 @@ public class FaultTolerantStepFactoryBeanTests {
void testProxiedItemStreamOpened() throws Exception {
writer.setFailures("4");
ItemStreamReader<String> reader = new ItemStreamReader<String>() {
ItemStreamReader<String> reader = new ItemStreamReader<>() {
@Override
public void close() throws ItemStreamException {
closed = true;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-2023 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.
@@ -35,25 +35,24 @@ import org.springframework.lang.Nullable;
class SimpleChunkProcessorTests {
private final SimpleChunkProcessor<String, String> processor = new SimpleChunkProcessor<>(
new ItemProcessor<String, String>() {
@Nullable
@Override
public String process(String item) throws Exception {
if (item.equals("err")) {
return null;
}
return item;
}
}, new ItemWriter<String>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
throw new RuntimeException("Planned failure!");
}
list.addAll(chunk.getItems());
}
});
private final SimpleChunkProcessor<String, String> processor = new SimpleChunkProcessor<>(new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {
if (item.equals("err")) {
return null;
}
return item;
}
}, new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> chunk) throws Exception {
if (chunk.getItems().contains("fail")) {
throw new RuntimeException("Planned failure!");
}
list.addAll(chunk.getItems());
}
});
private final StepContribution contribution = new StepContribution(
new StepExecution("foo", new JobExecution(new JobInstance(123L, "job"), new JobParameters())));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-2023 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.
@@ -47,8 +47,7 @@ class SimpleChunkProviderTests {
@Test
void testProvideWithOverflow() throws Exception {
provider = new SimpleChunkProvider<String>(new ListItemReader<>(Arrays.asList("foo", "bar")),
new RepeatTemplate()) {
provider = new SimpleChunkProvider<>(new ListItemReader<>(Arrays.asList("foo", "bar")), new RepeatTemplate()) {
@Override
protected String read(StepContribution contribution, Chunk<String> chunk)
throws SkipOverflowException, Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -71,7 +71,7 @@ class SimpleStepFactoryBeanTests {
private final List<String> written = new ArrayList<>();
private final ItemWriter<String> writer = new ItemWriter<String>() {
private final ItemWriter<String> writer = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
written.addAll(data.getItems());
@@ -175,7 +175,7 @@ class SimpleStepFactoryBeanTests {
SimpleStepFactoryBean<String, String> factory = getStepFactory(new String[] { "foo", "bar", "spam" });
factory.setItemWriter(new ItemWriter<String>() {
factory.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
throw new RuntimeException("Error!");
@@ -213,7 +213,7 @@ class SimpleStepFactoryBeanTests {
void testExceptionTerminates() throws Exception {
SimpleStepFactoryBean<String, String> factory = getStepFactory(new String[] { "foo", "bar", "spam" });
factory.setBeanName("exceptionStep");
factory.setItemWriter(new ItemWriter<String>() {
factory.setItemWriter(new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
throw new RuntimeException("Foo");
@@ -236,7 +236,7 @@ class SimpleStepFactoryBeanTests {
SimpleLimitExceptionHandler exceptionHandler = new SimpleLimitExceptionHandler(1);
exceptionHandler.afterPropertiesSet();
factory.setExceptionHandler(exceptionHandler);
factory.setItemWriter(new ItemWriter<String>() {
factory.setItemWriter(new ItemWriter<>() {
int count = 0;
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -47,7 +47,7 @@ class DefaultJobParametersExtractorJobParametersTests {
@BeforeEach
void setUp() {
DefaultConversionService conversionService = new DefaultConversionService();
conversionService.addConverter(String.class, LocalDate.class, new Converter<String, LocalDate>() {
conversionService.addConverter(String.class, LocalDate.class, new Converter<>() {
@Override
public LocalDate convert(String source) {
return LocalDate.parse(source);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -125,7 +125,7 @@ class AsyncChunkOrientedStepIntegrationTests {
step.setTasklet(new TestingChunkOrientedTasklet<>(
getReader(new String[] { "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c" }),
new ItemWriter<String>() {
new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
written.addAll(data.getItems());
@@ -142,7 +142,7 @@ class AsyncChunkOrientedStepIntegrationTests {
// Need a transaction so one connection is enough to get job execution and its
// parameters
StepExecution lastStepExecution = new TransactionTemplate(transactionManager)
.execute(new TransactionCallback<StepExecution>() {
.execute(new TransactionCallback<>() {
@Override
public StepExecution doInTransaction(TransactionStatus status) {
return jobRepository.getLastStepExecution(jobExecution.getJobInstance(), step.getName());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -58,7 +58,7 @@ class AsyncTaskletStepTests {
private int throttleLimit = 20;
ItemWriter<String> itemWriter = new ItemWriter<String>() {
ItemWriter<String> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
// Thread.sleep(100L);
@@ -176,7 +176,7 @@ class AsyncTaskletStepTests {
throttleLimit = 1;
concurrencyLimit = 1;
items = Arrays.asList("one", "barf", "three", "four");
itemProcessor = new ItemProcessor<String, String>() {
itemProcessor = new ItemProcessor<>() {
@Nullable
@Override
public String process(String item) throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -29,7 +29,7 @@ class CallableTaskletAdapterTests {
@Test
void testHandle() throws Exception {
adapter.setCallable(new Callable<RepeatStatus>() {
adapter.setCallable(new Callable<>() {
@Override
public RepeatStatus call() throws Exception {
return RepeatStatus.FINISHED;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-2023 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.
@@ -36,7 +36,7 @@ class ConfigurableSystemProcessExitCodeMapperTests {
*/
@Test
void testMapping() {
Map<Object, ExitStatus> mappings = new HashMap<Object, ExitStatus>() {
Map<Object, ExitStatus> mappings = new HashMap<>() {
{
put(0, ExitStatus.COMPLETED);
put(1, ExitStatus.FAILED);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -89,7 +89,7 @@ class StepExecutorInterruptionTests {
jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
step.setJobRepository(jobRepository);
step.setTransactionManager(this.transactionManager);
itemWriter = new ItemWriter<Object>() {
itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends Object> item) throws Exception {
}
@@ -107,7 +107,7 @@ class StepExecutorInterruptionTests {
RepeatTemplate template = new RepeatTemplate();
// N.B, If we don't set the completion policy it might run forever
template.setCompletionPolicy(new SimpleCompletionPolicy(2));
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<Object>() {
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<>() {
@Nullable
@Override
public Object read() throws Exception {
@@ -170,7 +170,7 @@ class StepExecutorInterruptionTests {
Thread processingThread = createThread(stepExecution);
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<Object>() {
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<>() {
@Nullable
@Override
public Object read() throws Exception {
@@ -216,7 +216,7 @@ class StepExecutorInterruptionTests {
}
});
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<Object>() {
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<>() {
@Nullable
@Override
public Object read() throws Exception {

View File

@@ -74,7 +74,7 @@ class TaskletStepTests {
private final List<Serializable> list = new ArrayList<>();
ItemWriter<String> itemWriter = new ItemWriter<String>() {
ItemWriter<String> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends String> data) throws Exception {
processed.addAll(data.getItems());
@@ -248,7 +248,7 @@ class TaskletStepTests {
@Test
void testIncrementRollbackCount() {
ItemReader<String> itemReader = new ItemReader<String>() {
ItemReader<String> itemReader = new ItemReader<>() {
@Nullable
@Override
@@ -274,7 +274,7 @@ class TaskletStepTests {
@Test
void testExitCodeDefaultClassification() {
ItemReader<String> itemReader = new ItemReader<String>() {
ItemReader<String> itemReader = new ItemReader<>() {
@Nullable
@Override
@@ -301,7 +301,7 @@ class TaskletStepTests {
@Test
void testExitCodeCustomClassification() {
ItemReader<String> itemReader = new ItemReader<String>() {
ItemReader<String> itemReader = new ItemReader<>() {
@Nullable
@Override
@@ -413,7 +413,7 @@ class TaskletStepTests {
*/
@Test
void testRestartJobOnNonRestartableTasklet() throws Exception {
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<String>() {
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<>() {
@Nullable
@Override
public String read() throws Exception {
@@ -609,7 +609,7 @@ class TaskletStepTests {
step.setInterruptionPolicy(interruptionPolicy);
ItemReader<String> itemReader = new ItemReader<String>() {
ItemReader<String> itemReader = new ItemReader<>() {
@Nullable
@Override
@@ -637,7 +637,7 @@ class TaskletStepTests {
@Test
void testStatusForNormalFailure() throws Exception {
ItemReader<String> itemReader = new ItemReader<String>() {
ItemReader<String> itemReader = new ItemReader<>() {
@Nullable
@Override
public String read() throws Exception {
@@ -662,7 +662,7 @@ class TaskletStepTests {
@Test
void testStatusForErrorFailure() throws Exception {
ItemReader<String> itemReader = new ItemReader<String>() {
ItemReader<String> itemReader = new ItemReader<>() {
@Nullable
@Override
public String read() throws Exception {
@@ -688,7 +688,7 @@ class TaskletStepTests {
@Test
void testStatusForResetFailedException() throws Exception {
ItemReader<String> itemReader = new ItemReader<String>() {
ItemReader<String> itemReader = new ItemReader<>() {
@Nullable
@Override
public String read() throws Exception {

View File

@@ -160,7 +160,7 @@ class HANAJobRepositoryIntegrationTests {
Ulimit[] ulimits = new Ulimit[] { new Ulimit("nofile", 1048576L, 1048576L) };
// create sysctls Map.
Map<String, String> sysctls = new HashMap<String, String>();
Map<String, String> sysctls = new HashMap<>();
sysctls.put("kernel.shmmax", "1073741824");
sysctls.put("net.ipv4.ip_local_port_range", "40000 60999");

View File

@@ -174,7 +174,7 @@ class MySQLJdbcJobRepositoryIntegrationTests {
public ConfigurableConversionService conversionService() {
DefaultConversionService conversionService = new DefaultConversionService();
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
conversionService.addConverter(String.class, Date.class, new Converter<String, Date>() {
conversionService.addConverter(String.class, Date.class, new Converter<>() {
@Override
public Date convert(String source) {
try {
@@ -185,7 +185,7 @@ class MySQLJdbcJobRepositoryIntegrationTests {
}
}
});
conversionService.addConverter(Date.class, String.class, new Converter<Date, String>() {
conversionService.addConverter(Date.class, String.class, new Converter<>() {
@Override
public String convert(Date source) {
return dateFormat.format(source);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2023 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.
@@ -213,13 +213,12 @@ class FaultTolerantStepFactoryBeanIntegrationTests {
}
public List<String> getCommitted() {
return jdbcTemplate.query("SELECT MESSAGE from ERROR_LOG where STEP_NAME='written'",
new RowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
});
return jdbcTemplate.query("SELECT MESSAGE from ERROR_LOG where STEP_NAME='written'", new RowMapper<>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
});
}
public void clear() {
@@ -260,13 +259,12 @@ class FaultTolerantStepFactoryBeanIntegrationTests {
}
public List<String> getCommitted() {
return jdbcTemplate.query("SELECT MESSAGE from ERROR_LOG where STEP_NAME='processed'",
new RowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
});
return jdbcTemplate.query("SELECT MESSAGE from ERROR_LOG where STEP_NAME='processed'", new RowMapper<>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
});
}
public void clear() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2023 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.
@@ -239,13 +239,12 @@ class FaultTolerantStepFactoryBeanRollbackIntegrationTests {
}
public List<String> getCommitted() {
return jdbcTemplate.query("SELECT MESSAGE from ERROR_LOG where STEP_NAME='written'",
new RowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
});
return jdbcTemplate.query("SELECT MESSAGE from ERROR_LOG where STEP_NAME='written'", new RowMapper<>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
});
}
public void clear() {
@@ -293,13 +292,12 @@ class FaultTolerantStepFactoryBeanRollbackIntegrationTests {
}
public List<String> getCommitted() {
return jdbcTemplate.query("SELECT MESSAGE from ERROR_LOG where STEP_NAME='processed'",
new RowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
});
return jdbcTemplate.query("SELECT MESSAGE from ERROR_LOG where STEP_NAME='processed'", new RowMapper<>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
});
}
public void clear() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2023 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.
@@ -156,7 +156,7 @@ class FaultTolerantStepIntegrationTests {
// Given
ListItemReader<Integer> itemReader = new ListItemReader<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7));
ItemProcessor<Integer, Integer> itemProcessor = new ItemProcessor<Integer, Integer>() {
ItemProcessor<Integer, Integer> itemProcessor = new ItemProcessor<>() {
private int cpt;
@Nullable
@@ -164,14 +164,14 @@ class FaultTolerantStepIntegrationTests {
public Integer process(Integer item) throws Exception {
cpt++;
if (cpt == 7) { // item 2 succeeds the first time but fails during the
// scan
// scan
throw new Exception("Error during process");
}
return item;
}
};
ItemWriter<Integer> itemWriter = new ItemWriter<Integer>() {
ItemWriter<Integer> itemWriter = new ItemWriter<>() {
private int cpt;
@Override
@@ -209,7 +209,7 @@ class FaultTolerantStepIntegrationTests {
// Given
ListItemReader<Integer> itemReader = new ListItemReader<>(Arrays.asList(1, 2, 3));
ItemProcessor<Integer, Integer> itemProcessor = new ItemProcessor<Integer, Integer>() {
ItemProcessor<Integer, Integer> itemProcessor = new ItemProcessor<>() {
@Override
public Integer process(Integer item) throws Exception {
if (item.equals(2)) {
@@ -219,7 +219,7 @@ class FaultTolerantStepIntegrationTests {
}
};
ItemWriter<Integer> itemWriter = new ItemWriter<Integer>() {
ItemWriter<Integer> itemWriter = new ItemWriter<>() {
@Override
public void write(Chunk<? extends Integer> chunk) throws Exception {
if (chunk.getItems().contains(3)) {