Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add possibility to add an exception handler to Watchers (#4365)
* feat: add possibility to add an exception handler to Informers * fix #4369: allowing the handler to determine if the stop or retry * fix #4369: refining the exception handler and adding back backoff * fix #4369: narrowing the changes to only a stopped future * feat: pass raw message to WatcherException, easier JSON error detection * fix #4369: refining the watch and informer reconnect and adding tests * cleaning up how the watch is stopped * just logging resourceeventhandler exceptions also stopping messages when a watch closes Co-authored-by: Steve Hawkins <shawkins@redhat.com>
- Loading branch information
Showing
16 changed files
with
295 additions
and
145 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
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
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
41 changes: 41 additions & 0 deletions
41
kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/WatcherExceptionTest.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,41 @@ | ||
/** | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.fabric8.kubernetes.client; | ||
|
||
import io.fabric8.kubernetes.api.model.Status; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.HttpURLConnection; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class WatcherExceptionTest { | ||
|
||
@Test | ||
void testIsHttpGone() { | ||
WatcherException we = new WatcherException("I've failed"); | ||
assertFalse(we.isHttpGone()); | ||
|
||
we = new WatcherException("I've failed", new ClassCastException()); | ||
assertFalse(we.isHttpGone()); | ||
|
||
we = new WatcherException("I've failed", | ||
new KubernetesClientException("http gone", HttpURLConnection.HTTP_GONE, new Status())); | ||
assertTrue(we.isHttpGone()); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.