Skip to content

Commit c3fdf1d

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

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
*
3636
* @author Gary Russell
3737
* @author Thomas Strauß
38+
* @author Kwon YongHyun
3839
*/
3940
public interface ProducerFactory<K, V> {
4041

4142
/**
4243
* The default close timeout duration as 30 seconds.
4344
*/
4445
Duration DEFAULT_PHYSICAL_CLOSE_TIMEOUT = Duration.ofSeconds(30);
46+
String FACTORY_DOES_NOT_SUPPORT_METHOD = "This factory does not support this method";
4547

4648
/**
4749
* Create a producer which will be transactional if the factory is so configured.
@@ -57,7 +59,7 @@ public interface ProducerFactory<K, V> {
5759
* @since 2.3
5860
*/
5961
default Producer<K, V> createProducer(@Nullable @SuppressWarnings("unused") String txIdPrefix) {
60-
throw new UnsupportedOperationException("This factory does not support this method");
62+
throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD);
6163
}
6264

6365
/**
@@ -67,7 +69,7 @@ default Producer<K, V> createProducer(@Nullable @SuppressWarnings("unused") Stri
6769
* @see #transactionCapable()
6870
*/
6971
default Producer<K, V> createNonTransactionalProducer() {
70-
throw new UnsupportedOperationException("This factory does not support this method");
72+
throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD);
7173
}
7274

7375
/**

0 commit comments

Comments
 (0)