diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/PulsarException.java b/spring-pulsar/src/main/java/org/springframework/pulsar/PulsarException.java index bbd28947..be45cff3 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/PulsarException.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/PulsarException.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,12 +30,12 @@ public class PulsarException extends NestedRuntimeException { super(msg); } - public PulsarException(String msg, Throwable cause) { - super(msg, cause); - } - public PulsarException(Throwable cause) { this(cause.getMessage(), cause); } + public PulsarException(String msg, Throwable cause) { + super(msg, cause); + } + } diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/CachingPulsarProducerFactory.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/CachingPulsarProducerFactory.java index 2aa9317a..49665586 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/CachingPulsarProducerFactory.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/CachingPulsarProducerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,10 +108,10 @@ public class CachingPulsarProducerFactory extends DefaultPulsarProducerFactor private Producer createCacheableProducer(Schema schema, String topic, @Nullable Collection encryptionKeys, @Nullable List> customizers) { - var producer = super.doCreateProducer(schema, topic, encryptionKeys, customizers); - return new ProducerWithCloseCallback<>(producer, - (p) -> this.logger.trace(() -> "Client closed producer %s but will skip actual closing" - .formatted(ProducerUtils.formatProducer(producer)))); + var producer = super.doCreateProducer(schema, topic, encryptionKeys, customizers); + return new ProducerWithCloseCallback<>(producer, + (p) -> this.logger.trace(() -> "Client closed producer %s but will skip actual closing" + .formatted(ProducerUtils.formatProducer(producer)))); } /** diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarClientFactory.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarClientFactory.java index d43238b4..ae25da16 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarClientFactory.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarClientFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarConsumerFactory.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarConsumerFactory.java index 03a3f402..ce389b5d 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarConsumerFactory.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarConsumerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarProducerFactory.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarProducerFactory.java index d6b1c160..5621a615 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarProducerFactory.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultPulsarProducerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,30 +110,13 @@ public class DefaultPulsarProducerFactory implements PulsarProducerFactory @Override public Producer createProducer(Schema schema, @Nullable String topic, @Nullable ProducerBuilderCustomizer customizer) { - try { - return doCreateProducer(schema, topic, null, - customizer != null ? Collections.singletonList(customizer) : null); - } - catch (PulsarException ex) { - throw ex; - } - catch (Exception ex) { - throw new PulsarException(PulsarClientException.unwrap(ex)); - } + return doCreateProducer(schema, topic, null, customizer != null ? Collections.singletonList(customizer) : null); } @Override public Producer createProducer(Schema schema, @Nullable String topic, @Nullable Collection encryptionKeys, @Nullable List> customizers) { - try { - return doCreateProducer(schema, topic, encryptionKeys, customizers); - } - catch (PulsarException ex) { - throw ex; - } - catch (Exception ex) { - throw new PulsarException(PulsarClientException.unwrap(ex)); - } + return doCreateProducer(schema, topic, encryptionKeys, customizers); } /** diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarClientFactory.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarClientFactory.java index 3e09349d..ba55527d 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarClientFactory.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarClientFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2023 the original author or authors. + * Copyright 2023-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarConsumerFactory.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarConsumerFactory.java index f36d19f7..4745457e 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarConsumerFactory.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarConsumerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarOperations.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarOperations.java index a43d85ff..17206272 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarOperations.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarProducerFactory.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarProducerFactory.java index 9d0cd69b..9cb35167 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarProducerFactory.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarProducerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarTemplate.java b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarTemplate.java index 563748e5..6233096d 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarTemplate.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/listener/DefaultPulsarMessageListenerContainer.java b/spring-pulsar/src/main/java/org/springframework/pulsar/listener/DefaultPulsarMessageListenerContainer.java index 233a1bef..19a62a6c 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/listener/DefaultPulsarMessageListenerContainer.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/listener/DefaultPulsarMessageListenerContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/listener/PulsarDeadLetterPublishingRecoverer.java b/spring-pulsar/src/main/java/org/springframework/pulsar/listener/PulsarDeadLetterPublishingRecoverer.java index b1ba66f4..4212af24 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/listener/PulsarDeadLetterPublishingRecoverer.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/listener/PulsarDeadLetterPublishingRecoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultPulsarClientFactoryTests.java b/spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultPulsarClientFactoryTests.java index 6e8eb934..e0c6567b 100644 --- a/spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultPulsarClientFactoryTests.java +++ b/spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultPulsarClientFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2023 the original author or authors. + * Copyright 2023-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultPulsarConsumerFactoryTests.java b/spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultPulsarConsumerFactoryTests.java index 89020e2b..1eaf0407 100644 --- a/spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultPulsarConsumerFactoryTests.java +++ b/spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultPulsarConsumerFactoryTests.java @@ -38,6 +38,7 @@ import org.junit.jupiter.api.Test; import org.mockito.InOrder; import org.springframework.lang.Nullable; +import org.springframework.pulsar.PulsarException; import org.springframework.pulsar.test.support.PulsarTestContainerSupport; /** @@ -86,7 +87,8 @@ class DefaultPulsarConsumerFactoryTests implements PulsarTestContainerSupport { @Test void withSchemaOnly() { assertThatThrownBy(() -> consumerFactory.createConsumer(SCHEMA, null, null, null, null)) - .isInstanceOf(InvalidConfigurationException.class) + .isInstanceOf(PulsarException.class) + .hasCauseInstanceOf(InvalidConfigurationException.class) .hasMessageContaining("Topic name must be set on the consumer builder"); } @@ -95,7 +97,8 @@ class DefaultPulsarConsumerFactoryTests implements PulsarTestContainerSupport { void withSchemaAndTopics() { assertThatThrownBy( () -> consumerFactory.createConsumer(SCHEMA, Collections.singletonList("topic0"), null, null, null)) - .isInstanceOf(InvalidConfigurationException.class) + .isInstanceOf(PulsarException.class) + .hasCauseInstanceOf(InvalidConfigurationException.class) .hasMessageContaining("Subscription name must be set on the consumer builder"); } diff --git a/spring-pulsar/src/test/java/org/springframework/pulsar/core/PulsarTemplateTests.java b/spring-pulsar/src/test/java/org/springframework/pulsar/core/PulsarTemplateTests.java index 67bdd616..e851d0bb 100644 --- a/spring-pulsar/src/test/java/org/springframework/pulsar/core/PulsarTemplateTests.java +++ b/spring-pulsar/src/test/java/org/springframework/pulsar/core/PulsarTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-pulsar/src/test/java/org/springframework/pulsar/reader/PulsarReaderStartMessageIdTests.java b/spring-pulsar/src/test/java/org/springframework/pulsar/reader/PulsarReaderStartMessageIdTests.java index 9d6bf415..7719fe7f 100644 --- a/spring-pulsar/src/test/java/org/springframework/pulsar/reader/PulsarReaderStartMessageIdTests.java +++ b/spring-pulsar/src/test/java/org/springframework/pulsar/reader/PulsarReaderStartMessageIdTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 the original author or authors. + * Copyright 2023-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -154,8 +154,9 @@ public class PulsarReaderStartMessageIdTests extends PulsarReaderTestsBase { for (int i = 0; i < 10; i++) { messageIds[i] = pulsarTemplate.send("with-customizer-reader-topic", "hello john doe-"); } - cb.startMessageId(messageIds[4]); // the first message read is the one - // after this message id. + // the first message read is the one after this message id + cb.startMessageId(messageIds[4]); + }; }