You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by ad...@apache.org on 2026/10/26 09:41:26 UTC
(polaris) branch main updated: Fix dev mode live reload failing with duplicate event bus codec (#5847)
This is an automated email from the ASF dual-hosted git repository.
adutra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 4e4bc24a23 Fix dev mode live reload failing with duplicate event bus codec (#5847)
4e4bc24a23 is described below
commit 4e4bc24a239c448427a8591370ec9130c2175f52
Author: Seungchul Lee <sc...@gmail.com>
AuthorDate: Mon Oct 26 18:41:20 2026 +0900
Fix dev mode live reload failing with duplicate event bus codec (#5847)
EventBusConfigurer registers a default codec for PolarisEvent on every StartupEvent but never unregisters it. In Quarkus dev mode the Vert.x EventBus survives a live reload, so the second registration throws "Already a codec registered with name polaris-events-local" and the application cannot restart.
Unregister the codec in a @PreDestroy method so that a restart can register it again.
Fixes #5844
---
.../polaris/service/events/EventBusConfigurer.java | 11 +++++++-
.../service/events/EventBusConfigurerTest.java} | 30 ++++++++++++++--------
2 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/runtime/service/src/main/java/org/apache/polaris/service/events/EventBusConfigurer.java b/runtime/service/src/main/java/org/apache/polaris/service/events/EventBusConfigurer.java
index c822599008..16f5482d46 100644
--- a/runtime/service/src/main/java/org/apache/polaris/service/events/EventBusConfigurer.java
+++ b/runtime/service/src/main/java/org/apache/polaris/service/events/EventBusConfigurer.java
@@ -22,14 +22,23 @@ package org.apache.polaris.service.events;
import io.quarkus.runtime.StartupEvent;
import io.quarkus.vertx.LocalEventBusCodec;
import io.vertx.core.eventbus.EventBus;
+import jakarta.annotation.PreDestroy;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
+import jakarta.inject.Inject;
@ApplicationScoped
public class EventBusConfigurer {
private static final String LOCAL_CODEC_NAME = "polaris-events-local";
- void configureEventBus(@Observes StartupEvent ev, EventBus eventBus) {
+ @Inject EventBus eventBus;
+
+ void registerEventCodec(@Observes StartupEvent ev) {
eventBus.registerDefaultCodec(PolarisEvent.class, new LocalEventBusCodec<>(LOCAL_CODEC_NAME));
}
+
+ @PreDestroy
+ void unregisterEventCodec() {
+ eventBus.unregisterDefaultCodec(PolarisEvent.class);
+ }
}
diff --git a/runtime/service/src/main/java/org/apache/polaris/service/events/EventBusConfigurer.java b/runtime/service/src/test/java/org/apache/polaris/service/events/EventBusConfigurerTest.java
similarity index 59%
copy from runtime/service/src/main/java/org/apache/polaris/service/events/EventBusConfigurer.java
copy to runtime/service/src/test/java/org/apache/polaris/service/events/EventBusConfigurerTest.java
index c822599008..af1cbb82a5 100644
--- a/runtime/service/src/main/java/org/apache/polaris/service/events/EventBusConfigurer.java
+++ b/runtime/service/src/test/java/org/apache/polaris/service/events/EventBusConfigurerTest.java
@@ -16,20 +16,28 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.polaris.service.events;
-import io.quarkus.runtime.StartupEvent;
-import io.quarkus.vertx.LocalEventBusCodec;
-import io.vertx.core.eventbus.EventBus;
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.enterprise.event.Observes;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+import io.vertx.core.Vertx;
+import org.junit.jupiter.api.Test;
+
+class EventBusConfigurerTest {
+
+ @Test
+ void testRegisterEventCodecAfterUnregisterEventCodec() {
+ Vertx vertx = Vertx.vertx();
+ try {
+ EventBusConfigurer configurer = new EventBusConfigurer();
+ configurer.eventBus = vertx.eventBus();
-@ApplicationScoped
-public class EventBusConfigurer {
- private static final String LOCAL_CODEC_NAME = "polaris-events-local";
+ configurer.registerEventCodec(null);
+ configurer.unregisterEventCodec();
- void configureEventBus(@Observes StartupEvent ev, EventBus eventBus) {
- eventBus.registerDefaultCodec(PolarisEvent.class, new LocalEventBusCodec<>(LOCAL_CODEC_NAME));
+ assertThatCode(() -> configurer.registerEventCodec(null)).doesNotThrowAnyException();
+ } finally {
+ vertx.close();
+ }
}
}