From 115dce171f2d140e9f56dd262633901954528678 Mon Sep 17 00:00:00 2001 From: David Festal Date: Tue, 16 May 2017 22:15:55 +0200 Subject: [PATCH] Fix 2 NPE that prevented using *non-dev* additional machines In the context of https://issues.jboss.org/browse/CHE-175 Signed-off-by: David Festal --- .../che/plugin/openshift/client/OpenShiftConnector.java | 6 ++++-- .../client/kubernetes/KubernetesLabelConverter.java | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java b/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java index 07f5b5ef9dc..a4bbd1eec92 100644 --- a/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java +++ b/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java @@ -1458,12 +1458,14 @@ private List getVolumeMountsFrom(String[] volumes, String workspace PersistentVolumeClaim pvc = getClaimCheWorkspace(); if (pvc != null) { String subPath = getWorkspaceSubpath(volumes); - VolumeMount vm = new VolumeMountBuilder() + if (subPath != null) { + VolumeMount vm = new VolumeMountBuilder() .withMountPath(cheWorkspaceProjectsStorage) .withName(workspacesPersistentVolumeClaim) .withSubPath(subPath) .build(); - vms.add(vm); + vms.add(vm); + } } return vms; } diff --git a/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/kubernetes/KubernetesLabelConverter.java b/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/kubernetes/KubernetesLabelConverter.java index e499117decd..2931e36ab57 100644 --- a/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/kubernetes/KubernetesLabelConverter.java +++ b/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/kubernetes/KubernetesLabelConverter.java @@ -64,6 +64,9 @@ public static String getCheServerLabelPrefix() { */ public static Map labelsToNames(Map labels) { Map names = new HashMap<>(); + if (labels == null) { + return names; + } for (Map.Entry label : labels.entrySet()) { if (!hasConversionProblems(label)) { @@ -103,6 +106,9 @@ public static Map labelsToNames(Map labels) { */ public static Map namesToLabels(Map names) { Map labels = new HashMap<>(); + if (names == null) { + return labels; + } for (Map.Entry entry: names.entrySet()){ String key = entry.getKey(); String value = entry.getValue();