Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ProducerFactory to use constant for repeated exception message #3550

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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