James Netherton created CAMEL-11020:
---------------------------------------

             Summary: Camel Kubernetes consumers do not close watchers
                 Key: CAMEL-11020
                 URL: https://issues.apache.org/jira/browse/CAMEL-11020
             Project: Camel
          Issue Type: Bug
          Components: camel-kubernetes
    Affects Versions: 2.18.3, 2.19.0
            Reporter: James Netherton


I've been experimenting with camel-kubernetes and noticed some odd behaviour 
after my camel context is shut down. It seems that not everything is cleaned up 
and there are still some background threads running.

I wrote a [unit 
test|https://github.com/jamesnetherton/wildfly-camel/blob/camel-kube/itests/camel/src/test/java/org/wildfly/camel/test/camel/kubernetes/KubernetesConsumerTest.java]
 that can help to replicate the problem. 

Run the test, then wait for the camel context to shut down. Afterwards, the 
thread will sleep for 5 minutes. During this time, stop the Kubernetes cluster 
and you'll see the following exception thrown (or something like it):

{code}
java.io.IOException: closed
        at 
okhttp3.internal.ws.WebSocketWriter.writeControlFrameSynchronized(WebSocketWriter.java:119)
        at 
okhttp3.internal.ws.WebSocketWriter.writeClose(WebSocketWriter.java:111)
        at okhttp3.internal.ws.RealWebSocket.close(RealWebSocket.java:168)
        at 
io.fabric8.kubernetes.client.dsl.internal.WatchConnectionManager$1.onClose(WatchConnectionManager.java:256)
        at okhttp3.internal.ws.RealWebSocket.peerClose(RealWebSocket.java:197)
        at okhttp3.internal.ws.RealWebSocket.access$200(RealWebSocket.java:38)
        at okhttp3.internal.ws.RealWebSocket$1$2.execute(RealWebSocket.java:84)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
{code}

Which indicates that the pod watcher was still active and connected to the k8s 
cluster, despite camel having been shutdown. This is not ideal when Camel is 
run within an OSGI or JavaEE container.




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to