Help port forwarding using the kubernetes-java library

Cluster information:

Kubernetes version: 1.21.4-gke.2300
Cloud being used: Google Cloud
Installation method: Hosted
Host OS: Unknown
Kubernetes-java version: 14.0.0
Java version: jdk1.8.0_291

I’m trying to use the official kubernetes-java client to enable kubernetes integration to my automated test suite. I’m now trying to add port forwarding support but the best I can do so far is get one HTTP request through. All subsequent attempts result in a “Broken Pipe”. If I manually port forward using the command-line client, it works as expected, but given the various environments this will run in, I’m trying to use a pure java implementation to minimize setup dependencies.

Since it works from the command-line it must be something in how either I’ve implemented it or the Java client.

Does anyone know of any examples that work or have suggestions on what the process is?

I patterned my code initially after the PortForward example at: but I think I’m missing something on how to keep things open until the test completes or until explicitly closed.