Skip to content

Commit

Permalink
fix fabric8io#4641: addressing a regression that misses initial watch…
Browse files Browse the repository at this point in the history
… event
  • Loading branch information
shawkins committed Dec 5, 2022
1 parent 9b248dd commit a2add7e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
* Fix #4534: Java Generator CLI default handling of skipGeneratedAnnotations
* Fix #4535: The shell command string will now have single quotes sanitized
* Fix #4543: (Java Generator) additionalProperties JsonAny setter method generated as setAdditionalProperty
* Fix #4641: fixed regression with missing initial watch event
* Fix #4547: preventing timing issues with leader election cancel
* Fix #4540: treating GenericKubernetesResource and RawExtension as buildable
* Fix #4569: fixing jdk httpclient regression with 0 timeouts
Expand Down
Expand Up @@ -39,9 +39,6 @@

public class KubernetesNamespacedTestExtension implements BeforeAllCallback, BeforeEachCallback, AfterAllCallback {

private static final ExtensionContext.Namespace EXT_NAMESPACE = ExtensionContext.Namespace
.create(KubernetesNamespacedTestExtension.class);

@Override
public void beforeAll(ExtensionContext context) throws Exception {
final KubernetesClient client = new KubernetesClientBuilder().build();
Expand Down Expand Up @@ -82,7 +79,9 @@ static KubernetesClient getClient(ExtensionContext context) {
}

private static ExtensionContext.Store getStore(ExtensionContext context) {
return context.getRoot().getStore(EXT_NAMESPACE);
ExtensionContext.Namespace namespace = ExtensionContext.Namespace.create(KubernetesNamespacedTestExtension.class,
context.getRequiredTestClass());
return context.getRoot().getStore(namespace);
}

/**
Expand Down
Expand Up @@ -55,6 +55,7 @@ public class WatchConnectionManager<T extends HasMetadata, L extends KubernetesR
private WebSocket websocket;

private volatile boolean ready;
private volatile boolean closed;

static void closeWebSocket(WebSocket webSocket) {
if (webSocket != null) {
Expand Down Expand Up @@ -87,6 +88,7 @@ public WatchConnectionManager(final HttpClient client, final BaseOperation<T, L,

@Override
protected synchronized void closeRequest() {
closed = true;
closeWebSocket(websocket);
Optional.ofNullable(this.websocketFuture).ifPresent(theFuture -> {
this.websocketFuture = null;
Expand All @@ -109,7 +111,7 @@ public CompletableFuture<WebSocket> getWebsocketFuture() {
@Override
protected void onMessage(String message) {
// for consistency we only want to process the message when we're open
if (this.websocketFuture != null) {
if (!closed) {
super.onMessage(message);
}
}
Expand Down

0 comments on commit a2add7e

Please sign in to comment.