Skip to content

Commit 76c37ad

Browse files
committed
Clear network interceptors after async calls
1 parent 34db93f commit 76c37ad

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

operator/src/main/java/oracle/kubernetes/operator/helpers/ClientPool.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ private ApiClient getApiClient() {
8585
return client;
8686
}
8787

88+
@Override
89+
protected ApiClient onRecycle(ApiClient instance) {
90+
// Work around async processing creating, but not cleaning-up network interceptors
91+
instance.getHttpClient().networkInterceptors().clear();
92+
return super.onRecycle(instance);
93+
}
94+
8895
private static class DefaultClientFactory implements ClientFactory {
8996
private final AtomicBoolean first = new AtomicBoolean(true);
9097

operator/src/main/java/oracle/kubernetes/operator/helpers/Pool.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ protected Queue<T> getQueue() {
4646
* @param instance Pool object to recycle
4747
*/
4848
public final void recycle(T instance) {
49-
getQueue().offer(instance);
49+
getQueue().offer(onRecycle(instance));
5050
if (LOGGER.isFinerEnabled()) {
5151
LOGGER.finer("Recycling instance to pool, instances now in pool: " + getQueue().size());
5252
}
5353
}
5454

55+
protected T onRecycle(T instance) {
56+
return instance;
57+
}
58+
5559
/**
5660
* Creates a new instance of object. This method is used when someone wants to {@link #take()
5761
* take} an object from an empty pool. Also note that multiple threads may call this method

0 commit comments

Comments
 (0)