5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-20 10:51:21 +08:00

SQOOP-2484: Sqoop2: Findbugs: Fix resource leak problem in SqoopConfiguration and ConnectorManagerUtils

(Colin Ma via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2015-08-18 08:52:30 -07:00
parent 354a6969ef
commit 7ce9f67f71
2 changed files with 7 additions and 8 deletions

View File

@ -71,9 +71,9 @@ public static List<URL> getConnectorConfigs() {
}
static boolean isConnectorJar(File file) {
try {
try (JarFile jarFile = new JarFile(file)) {
@SuppressWarnings("resource")
JarEntry entry = new JarFile(file).getJarEntry(ConfigurationConstants.FILENAME_CONNECTOR_PROPERTIES);
JarEntry entry = jarFile.getJarEntry(ConfigurationConstants.FILENAME_CONNECTOR_PROPERTIES);
return entry != null;
} catch (IOException e) {
throw new RuntimeException(e);

View File

@ -129,9 +129,7 @@ public synchronized void initialize() {
}
Properties bootstrapProperties = new Properties();
InputStream bootstrapPropStream = null;
try {
bootstrapPropStream = new FileInputStream(bootstrapConfig);
try (InputStream bootstrapPropStream = new FileInputStream(bootstrapConfig)) {
bootstrapProperties.load(bootstrapPropStream);
} catch (IOException ex) {
throw new SqoopException(
@ -267,11 +265,12 @@ private synchronized void configureClassLoader(String classpathProperty) {
private synchronized void configureLogging() {
Properties props = new Properties();
for (String key : config.keySet()) {
for (Map.Entry<String, String> entry : config.entrySet()) {
String key = entry.getKey();
if (key.startsWith(ConfigurationConstants.PREFIX_LOG_CONFIG)) {
String logConfigKey = key.substring(
ConfigurationConstants.PREFIX_GLOBAL_CONFIG.length());
props.put(logConfigKey, config.get(key));
props.put(logConfigKey, entry.getValue());
}
}