forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#36537 from ozangunalp/apicurio_continuou…
…s_testing_fix Reset the Apicurio registry client in dev mode and tests
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...st/java/io/quarkus/apicurio/registry/common/ApicurioRegistryInternalsExpectationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.quarkus.apicurio.registry.common; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.apicurio.rest.client.spi.ApicurioHttpClientFactory; | ||
|
||
public class ApicurioRegistryInternalsExpectationTest { | ||
@Test | ||
public void test() throws NoSuchFieldException { | ||
// we need this to reset the client in continuous testing | ||
ApicurioHttpClientFactory.class.getDeclaredField("providerReference"); | ||
} | ||
} |
22 changes: 21 additions & 1 deletion
22
...mon/runtime/src/main/java/io/quarkus/apicurio/registry/common/ApicurioRegistryClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
package io.quarkus.apicurio.registry.common; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import io.apicurio.registry.rest.client.RegistryClientFactory; | ||
import io.apicurio.rest.client.VertxHttpClientProvider; | ||
import io.apicurio.rest.client.spi.ApicurioHttpClientFactory; | ||
import io.quarkus.runtime.RuntimeValue; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
import io.vertx.core.Vertx; | ||
|
||
@Recorder | ||
public class ApicurioRegistryClient { | ||
|
||
private static final Logger log = Logger.getLogger(ApicurioRegistryClient.class); | ||
|
||
public void setup(RuntimeValue<Vertx> vertx) { | ||
RegistryClientFactory.setProvider(new VertxHttpClientProvider(vertx.getValue())); | ||
} | ||
} | ||
|
||
public void clearHttpClient() { | ||
try { | ||
Field providerReference = ApicurioHttpClientFactory.class.getDeclaredField("providerReference"); | ||
providerReference.setAccessible(true); | ||
AtomicReference ref = (AtomicReference) providerReference.get(null); | ||
ref.set(null); | ||
} catch (NoSuchFieldException | IllegalAccessException t) { | ||
log.error("Failed to clear Apicurio Http Client provider", t); | ||
} | ||
} | ||
} |