Skip to content

Commit 7207305

Browse files
Update state check error message to include failure hint.
Original Pull Request: #2013
1 parent 73650cf commit 7207305

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

Diff for: src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,7 @@ public AbstractRedisClient getRequiredNativeClient() {
820820

821821
AbstractRedisClient client = getNativeClient();
822822

823-
if (client == null) {
824-
throw new IllegalStateException("Client not yet initialized");
825-
}
823+
Assert.state(client != null, "Client not yet initialized. Did you forget to call initialize the bean?");
826824

827825
return client;
828826
}

Diff for: src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryUnitTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ void getNativeClientShouldFailIfNotInitialized() {
10111011
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory();
10121012

10131013
assertThatIllegalStateException().isThrownBy(connectionFactory::getRequiredNativeClient)
1014-
.withMessage("Client not yet initialized");
1014+
.withMessageContaining("Client not yet initialized");
10151015
}
10161016

10171017
@Data

0 commit comments

Comments
 (0)