mirror of https://github.com/apache/cloudstack.git
Fix for Coverity issues CID_1116744, CID_1116718 and CID_1116682, all related to resource leak
Signed-off-by: Daan Hoogland <daan@onecht.net>
This commit is contained in:
parent
de2c4ceeb9
commit
226b193488
|
|
@ -32,6 +32,8 @@ import java.util.Set;
|
|||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
//
|
||||
// Finding classes in a given package code is taken and modified from
|
||||
// Credit: http://internna.blogspot.com/2007/11/java-5-retrieving-all-classes-from.html
|
||||
|
|
@ -39,7 +41,7 @@ import java.util.jar.JarInputStream;
|
|||
public class OnwireClassRegistry {
|
||||
|
||||
private List<String> packages = new ArrayList<String>();
|
||||
private Map<String, Class<?>> registry = new HashMap<String, Class<?>>();
|
||||
private final Map<String, Class<?>> registry = new HashMap<String, Class<?>>();
|
||||
|
||||
public OnwireClassRegistry() {
|
||||
registry.put("Object", Object.class);
|
||||
|
|
@ -166,13 +168,15 @@ public class OnwireClassRegistry {
|
|||
}
|
||||
}
|
||||
}
|
||||
IOUtils.closeQuietly(jarFile);
|
||||
}
|
||||
} while (jarEntry != null);
|
||||
|
||||
IOUtils.closeQuietly(jarFile);
|
||||
return classes;
|
||||
}
|
||||
|
||||
static String stripFilenameExtension(String file) {
|
||||
return file.substring(0, file.lastIndexOf('.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,11 +41,6 @@ import java.util.TreeMap;
|
|||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
|
|
@ -61,11 +56,14 @@ import org.apache.cloudstack.api.response.StoragePoolResponse;
|
|||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IteratorUtil;
|
||||
import com.cloud.utils.ReflectUtil;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
public class ApiXmlDocWriter {
|
||||
public static final Logger s_logger = Logger.getLogger(ApiXmlDocWriter.class.getName());
|
||||
|
|
@ -136,6 +134,7 @@ public class ApiXmlDocWriter {
|
|||
try {
|
||||
FileInputStream in = new FileInputStream(fileName);
|
||||
preProcessedCommands.load(in);
|
||||
in.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
System.out.println("Can't find file " + fileName);
|
||||
System.exit(2);
|
||||
|
|
@ -395,13 +394,13 @@ public class ApiXmlDocWriter {
|
|||
// Generate request
|
||||
request.add(new Argument("username", "Username", true));
|
||||
request.add(new Argument(
|
||||
"password",
|
||||
"Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.",
|
||||
true));
|
||||
"password",
|
||||
"Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.",
|
||||
true));
|
||||
request.add(new Argument("domain",
|
||||
"path of the domain that the user belongs to. Example: domain=/com/cloud/internal. If no domain is passed in, the ROOT domain is assumed.", false));
|
||||
"path of the domain that the user belongs to. Example: domain=/com/cloud/internal. If no domain is passed in, the ROOT domain is assumed.", false));
|
||||
request.add(new Argument("domainId",
|
||||
"id of the domain that the user belongs to. If both domain and domainId are passed in, \"domainId\" parameter takes precendence", false));
|
||||
"id of the domain that the user belongs to. If both domain and domainId are passed in, \"domainId\" parameter takes precendence", false));
|
||||
apiCommand.setRequest(request);
|
||||
|
||||
// Generate response
|
||||
|
|
|
|||
Loading…
Reference in New Issue