Skip to content

Commit 16133e2

Browse files
authored
Refactor ProducerFactory to use constant for repeated exception message (#3550)
1 parent 6ce3442 commit 16133e2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

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

@@ -43,6 +44,11 @@ public interface ProducerFactory<K, V> {
4344
*/
4445
Duration DEFAULT_PHYSICAL_CLOSE_TIMEOUT = Duration.ofSeconds(30);
4546

47+
/**
48+
* Error message for unsupported factory methods.
49+
*/
50+
String FACTORY_DOES_NOT_SUPPORT_METHOD = "This factory does not support this method";
51+
4652
/**
4753
* Create a producer which will be transactional if the factory is so configured.
4854
* @return the producer.
@@ -57,7 +63,7 @@ public interface ProducerFactory<K, V> {
5763
* @since 2.3
5864
*/
5965
default Producer<K, V> createProducer(@Nullable @SuppressWarnings("unused") String txIdPrefix) {
60-
throw new UnsupportedOperationException("This factory does not support this method");
66+
throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD);
6167
}
6268

6369
/**
@@ -67,7 +73,7 @@ default Producer<K, V> createProducer(@Nullable @SuppressWarnings("unused") Stri
6773
* @see #transactionCapable()
6874
*/
6975
default Producer<K, V> createNonTransactionalProducer() {
70-
throw new UnsupportedOperationException("This factory does not support this method");
76+
throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD);
7177
}
7278

7379
/**

0 commit comments

Comments
 (0)