Skip to content

Commit

Permalink
Merge pull request quarkusio#10546 from stuartwdouglas/6209
Browse files Browse the repository at this point in the history
Hot reload logging fixes
  • Loading branch information
mkouba authored Jul 8, 2020
2 parents 5e43ab8 + a30ab3f commit 91015de
Showing 3 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@

public class IsolatedDevModeMain implements BiConsumer<CuratedApplication, Map<String, Object>>, Closeable {

private static final Logger log = Logger.getLogger(DevModeMain.class);
private static final Logger log = Logger.getLogger(IsolatedDevModeMain.class);
public static final String APP_ROOT = "app-root";

private volatile DevModeContext context;
@@ -101,7 +101,6 @@ public void accept(Integer integer) {
} else {
//we need to set this here, while we still have the correct TCCL
//this is so the config is still valid, and we can read HTTP config from application.properties
log.error("Failed to start Quarkus", t);
log.info("Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure");
if (runtimeUpdatesProcessor != null) {
Thread.currentThread().setContextClassLoader(curatedApplication.getBaseRuntimeClassLoader());
@@ -142,6 +141,8 @@ public synchronized void restartApp(Set<String> changedResources) {
} catch (Throwable t) {
deploymentProblem = t;
log.error("Failed to start quarkus", t);
Thread.currentThread().setContextClassLoader(curatedApplication.getAugmentClassLoader());
LoggingSetupRecorder.handleFailedStart();
}
} finally {
restarting = false;
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.inject.Singleton;

import org.jboss.logging.Logger;
@@ -34,25 +33,22 @@ public class VertxProducer {

private static final Logger LOGGER = Logger.getLogger(VertxProducer.class);

@Inject
Vertx vertx;

@Singleton
@Produces
public EventBus eventbus() {
public EventBus eventbus(Vertx vertx) {
return vertx.eventBus();
}

@Singleton
@Produces
public io.vertx.mutiny.core.Vertx mutiny() {
public io.vertx.mutiny.core.Vertx mutiny(Vertx vertx) {
return io.vertx.mutiny.core.Vertx.newInstance(vertx);
}

@Singleton
@Produces
@Deprecated
public io.vertx.axle.core.Vertx axle() {
public io.vertx.axle.core.Vertx axle(Vertx vertx) {
LOGGER.warn(
"`io.vertx.axle.core.Vertx` is deprecated and will be removed in a future version - it is "
+ "recommended to switch to `io.vertx.mutiny.core.Vertx`");
@@ -62,7 +58,7 @@ public io.vertx.axle.core.Vertx axle() {
@Singleton
@Produces
@Deprecated
public io.vertx.reactivex.core.Vertx rx() {
public io.vertx.reactivex.core.Vertx rx(Vertx vertx) {
LOGGER.warn(
"`io.vertx.reactivex.core.Vertx` is deprecated and will be removed in a future version - it is "
+ "recommended to switch to `io.vertx.mutiny.core.Vertx`");
@@ -102,8 +98,7 @@ public io.vertx.mutiny.core.eventbus.EventBus mutinyEventBus(io.vertx.mutiny.cor
* @param event
* @param beanManager
*/
void undeployVerticles(@Observes @BeforeDestroyed(ApplicationScoped.class) Object event,
BeanManager beanManager, io.vertx.mutiny.core.Vertx mutiny) {
void undeployVerticles(@Observes @BeforeDestroyed(ApplicationScoped.class) Object event, BeanManager beanManager) {
// Only beans with the AbstractVerticle in the set of bean types are considered - we need a deployment id
Set<Bean<?>> beans = beanManager.getBeans(AbstractVerticle.class, Any.Literal.INSTANCE);
Context applicationContext = beanManager.getContext(ApplicationScoped.class);
@@ -115,6 +110,8 @@ void undeployVerticles(@Observes @BeforeDestroyed(ApplicationScoped.class) Objec
// Only existing instances are considered
try {
AbstractVerticle verticle = (AbstractVerticle) instance;
io.vertx.mutiny.core.Vertx mutiny = beanManager.createInstance()
.select(io.vertx.mutiny.core.Vertx.class).get();
mutiny.undeploy(verticle.deploymentID()).await().indefinitely();
LOGGER.debugf("Undeployed verticle: %s", instance.getClass());
} catch (Exception e) {
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
import org.junit.jupiter.api.Test;

import io.quarkus.vertx.core.runtime.VertxCoreRecorder;
import io.vertx.core.Vertx;

public class VertxProducerTest {

@@ -27,24 +28,23 @@ public void tearDown() {

@Test
public void shouldNotFailWithoutConfig() {
producer.vertx = VertxCoreRecorder.initialize(null, null);
verifyProducer();
verifyProducer(VertxCoreRecorder.initialize(null, null));
}

private void verifyProducer() {
assertThat(producer.eventbus()).isNotNull();
private void verifyProducer(Vertx v) {
assertThat(producer.eventbus(v)).isNotNull();

assertThat(producer.axle()).isNotNull();
assertFalse(producer.axle().isClustered());
assertThat(producer.axleEventBus(producer.axle())).isNotNull();
assertThat(producer.axle(v)).isNotNull();
assertFalse(producer.axle(v).isClustered());
assertThat(producer.axleEventBus(producer.axle(v))).isNotNull();

assertThat(producer.rx()).isNotNull();
assertFalse(producer.rx().isClustered());
assertThat(producer.rxEventBus(producer.rx())).isNotNull();
assertThat(producer.rx(v)).isNotNull();
assertFalse(producer.rx(v).isClustered());
assertThat(producer.rxEventBus(producer.rx(v))).isNotNull();

assertThat(producer.mutiny()).isNotNull();
assertFalse(producer.mutiny().isClustered());
assertThat(producer.mutinyEventBus(producer.mutiny())).isNotNull();
assertThat(producer.mutiny(v)).isNotNull();
assertFalse(producer.mutiny(v).isClustered());
assertThat(producer.mutinyEventBus(producer.mutiny(v))).isNotNull();

}
}

0 comments on commit 91015de

Please sign in to comment.