Fix 3 findbugs encoding warnings in VmwareStorageProcessor.java Ova templates and metadata should be written to file in UTF-8 Fix warning in UUID generation

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #411
This commit is contained in:
Rafael da Fonseca 2015-06-14 14:17:40 +02:00 committed by Rohit Yadav
parent ccd7d41ee3
commit 85ad1b7e0f
1 changed files with 10 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.io.UnsupportedEncodingException;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
@ -680,7 +681,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
// TODO a bit ugly here
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(installFullPath + "/template.properties")));
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(installFullPath + "/template.properties"),"UTF-8"));
out.write("filename=" + templateName + ".ova");
out.newLine();
out.write("description=");
@ -859,7 +860,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
// TODO a bit ugly here
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(installFullPath + "/" + templateName + ".ova.meta")));
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(installFullPath + "/" + templateName + ".ova.meta"),"UTF-8"));
out.write("ova.filename=" + templateName + ".ova");
out.newLine();
out.write("version=1.0");
@ -1388,7 +1389,13 @@ public class VmwareStorageProcessor implements StorageProcessor {
}
private static String getSecondaryDatastoreUUID(String storeUrl) {
return UUID.nameUUIDFromBytes(storeUrl.getBytes()).toString();
String uuid = null;
try{
uuid=UUID.nameUUIDFromBytes(storeUrl.getBytes("UTF-8")).toString();
}catch(UnsupportedEncodingException e){
s_logger.warn("Failed to create UUID from string " + storeUrl + ". Bad storeUrl or UTF-8 encoding error." );
}
return uuid;
}
public synchronized ManagedObjectReference prepareSecondaryDatastoreOnHost(String storeUrl) throws Exception {