From 474065e98b57d666dc4f6403242fd55a201aed25 Mon Sep 17 00:00:00 2001 From: Rafael da Fonseca Date: Sun, 14 Jun 2015 13:38:09 +0200 Subject: [PATCH] Fix findbugs encoding warning in VmwareServerDiscoverer.java Input string should only contain safe characters, since it's derived from a Long object. This just gets rid of the findbugs warning Signed-off-by: Rohit Yadav This closes #408 --- .../com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index 1a8f8dafd71..ca98c4f096e 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@ -398,7 +398,11 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer } // place a place holder guid derived from cluster ID - cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString()); + try{ + cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes("UTF-8")).toString()); + }catch(UnsupportedEncodingException e){ + throw new DiscoveredWithErrorException("Unable to create UUID based on string " + String.valueOf(clusterId) + ". Bad clusterId or UTF-8 encoding error."); + } _clusterDao.update(clusterId, cluster); // Flag cluster discovery success failureInClusterDiscovery = false;