Skip to content

Commit 7e80321

Browse files
committed
Refactor ProducerFactory to use constant for repeated exception message
1 parent 96ee5c2 commit 7e80321

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-kafka/src/main/java/org/springframework/kafka/core/ProducerFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public interface ProducerFactory<K, V> {
4242
* The default close timeout duration as 30 seconds.
4343
*/
4444
Duration DEFAULT_PHYSICAL_CLOSE_TIMEOUT = Duration.ofSeconds(30);
45+
String FACTORY_DOES_NOT_SUPPORT_METHOD = "This factory does not support this method";
4546

4647
/**
4748
* Create a producer which will be transactional if the factory is so configured.
@@ -57,7 +58,7 @@ public interface ProducerFactory<K, V> {
5758
* @since 2.3
5859
*/
5960
default Producer<K, V> createProducer(@Nullable @SuppressWarnings("unused") String txIdPrefix) {
60-
throw new UnsupportedOperationException("This factory does not support this method");
61+
throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD);
6162
}
6263

6364
/**
@@ -67,7 +68,7 @@ default Producer<K, V> createProducer(@Nullable @SuppressWarnings("unused") Stri
6768
* @see #transactionCapable()
6869
*/
6970
default Producer<K, V> createNonTransactionalProducer() {
70-
throw new UnsupportedOperationException("This factory does not support this method");
71+
throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD);
7172
}
7273

7374
/**

0 commit comments

Comments
 (0)