jkube: PortForwardTask.java: Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.

Description

The following statement is reported as a Bug by SonarCloud:

https://github.com/eclipse/jkube/blob/af40c8f27af57f9651f8ebb1634df33eaf909f6a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/portforward/PortForwardTask.java#L49-L51

  • should be changed to:
    } catch (InterruptedException ex) {
      Thread.currentThread().interrupt();
    } catch (Exception exception) {
      logger.warn("Not able to port forward: %s", exception.getMessage());
    } finally {

How to manually test my changes

Kubernetes

If you don’t have a real Kubernetes cluster available (most probably), you can use Minikube or Kind to test with a local cluster.

OpenShift

If you don’t have a real OpenShift cluster available (most probably), you can use Red Hat’s developer Sandbox for Red Hat OpenShift. The only requirement is to have a Red Hat account.

Once you have your Sandbox environment, you’ll need to download the oc tool from the cluster console. (Press the ? icon and from the context menu select Command line tools, you’ll be redirected to https://$subdomain.openshiftapps.com/command-lines-tools where you’ll be able to download the CLI for your platform)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (16 by maintainers)

Most upvoted comments

@manusa , Can I contribute on this? I don’t know the manually testing part though but I know Java Exception Handling.

Hello @manusa
Sorry for the delay. As per the description, I made the changes for exception handling. The only issue that I encountered was related to testing part.
I use Windows and thus, I use Docker Desktop with WSL2 enabled. So through Windows Terminal, I first checked for the installation of all the required software such as Docker, Minikube, Kubernetes, Kubectl and found them to be installed properly. Then I proceeded with the commands (in Windows Terminal) that you have shown in example in the comment as follows:

  1. Changed the directory to the ‘jkube’.
  2. Executed eval $(minikube docker-env), which executed successfully.
  3. Executed mvn clean install -DskipTests, which I think executed successfully as I got message of “BUILD SUCCESS” at the end. It was a long process and took 30 minutes.
  4. Changed directory to ‘spring-boot’.
  5. Executed mvn -Djkube.version=1.5.0-SNAPSHOT -Pkubernetes clean package k8s:build k8s:resource k8s:apply. At first, it gave error as I had not enabled Kubernetes from settings in Docker Desktop. After enabling Kubernetes, it executed successfully as I got the message of “BUILD SUCCESS” at the end.
  6. Then I executed mvn k8s:debug but it gave me an error as below:   [ERROR] No plugin found for prefix ‘k8s’ in the current project and in the plugin groups [org.apache.maven.plugins,   org.codehaus.mojo] available from the repositories [local (/home/shubham/.m2/repository), central   (https://repo.maven.apache.org/maven2)] -> [Help 1]   [ERROR]   [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.   [ERROR] Re-run Maven using the -X switch to enable full debug logging.   [ERROR]   [ERROR] For more information about the errors and possible solutions, please read the following articles:   [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

I am unable to understand the cause of the error as I have already enabled Kubernetes and upon checking the version for Kubernetes, terminal displays it. Also, I got this same error while executing mvn -Djkube .version… line when I hadn’t installed Kubernetes earlier but it got resolved after installing and enabling Kubernetes.

I have attached the entire terminal session here for your reference. Windows_Terminal_Session.txt