Throw IllegalStateException from afterPropertiesSet

Consistently use Assert.state in the afterPropertiesSet()
methods to throw IllegalStateException instead of
IllegalArgumentException when some properties are missing
and/or invalid.

Resolves #2244
This commit is contained in:
Danilo Piazzalunga
2022-02-07 08:17:38 +01:00
committed by Mahmoud Ben Hassine
parent b9d6e26d61
commit fc0ec01ff8
96 changed files with 188 additions and 178 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 the original author or authors.
* Copyright 2006-2022 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.
@@ -59,7 +59,7 @@ public class AsyncItemProcessor<I, O> implements ItemProcessor<I, Future<O>>, In
* @see InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception {
Assert.notNull(delegate, "The delegate must be set.");
Assert.state(delegate != null, "The delegate must be set.");
}
/**

View File

@@ -39,7 +39,7 @@ public class AsyncItemWriter<T> implements ItemStreamWriter<Future<T>>, Initiali
private ItemWriter<T> delegate;
public void afterPropertiesSet() throws Exception {
Assert.notNull(delegate, "A delegate ItemWriter must be provided.");
Assert.state(delegate != null, "A delegate ItemWriter must be provided.");
}
/**

View File

@@ -56,7 +56,7 @@ public class ChunkProcessorChunkHandler<S> implements ChunkHandler<S>, Initializ
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception {
Assert.notNull(chunkProcessor, "A ChunkProcessor must be provided");
Assert.state(chunkProcessor != null, "A ChunkProcessor must be provided");
}
/**

View File

@@ -111,7 +111,7 @@ public class MessageChannelPartitionHandler extends AbstractPartitionHandler imp
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(stepName, "A step name must be provided for the remote workers.");
Assert.state(stepName != null, "A step name must be provided for the remote workers.");
Assert.state(messagingGateway != null, "The MessagingOperations must be set");
pollRepositoryForResults = !(dataSource == null && jobExplorer == null);

View File

@@ -46,7 +46,7 @@ class AsyncItemProcessorTests {
@Test
void testNoDelegate() {
assertThrows(IllegalArgumentException.class, processor::afterPropertiesSet);
assertThrows(IllegalStateException.class, processor::afterPropertiesSet);
}
@Test