Skip to content

Commit

Permalink
Refactor ProducerFactory to use constant for repeated exception messa…
Browse files Browse the repository at this point in the history
…ge (#3550)
  • Loading branch information
kwonyonghyun authored Oct 9, 2024
1 parent 6ce3442 commit 16133e2
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*
* @author Gary Russell
* @author Thomas Strauß
* @author Kwon YongHyun
*/
public interface ProducerFactory<K, V> {

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

/**
* Error message for unsupported factory methods.
*/
String FACTORY_DOES_NOT_SUPPORT_METHOD = "This factory does not support this method";

/**
* Create a producer which will be transactional if the factory is so configured.
* @return the producer.
Expand All @@ -57,7 +63,7 @@ public interface ProducerFactory<K, V> {
* @since 2.3
*/
default Producer<K, V> createProducer(@Nullable @SuppressWarnings("unused") String txIdPrefix) {
throw new UnsupportedOperationException("This factory does not support this method");
throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD);
}

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

/**
Expand Down

0 comments on commit 16133e2

Please sign in to comment.