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:
parent
354a6969ef
commit
7ce9f67f71
@ -71,12 +71,12 @@ public static List<URL> getConnectorConfigs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean isConnectorJar(File file) {
|
static boolean isConnectorJar(File file) {
|
||||||
try {
|
try (JarFile jarFile = new JarFile(file)) {
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
JarEntry entry = new JarFile(file).getJarEntry(ConfigurationConstants.FILENAME_CONNECTOR_PROPERTIES);
|
JarEntry entry = jarFile.getJarEntry(ConfigurationConstants.FILENAME_CONNECTOR_PROPERTIES);
|
||||||
return entry != null;
|
return entry != null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -129,9 +129,7 @@ public synchronized void initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Properties bootstrapProperties = new Properties();
|
Properties bootstrapProperties = new Properties();
|
||||||
InputStream bootstrapPropStream = null;
|
try (InputStream bootstrapPropStream = new FileInputStream(bootstrapConfig)) {
|
||||||
try {
|
|
||||||
bootstrapPropStream = new FileInputStream(bootstrapConfig);
|
|
||||||
bootstrapProperties.load(bootstrapPropStream);
|
bootstrapProperties.load(bootstrapPropStream);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new SqoopException(
|
throw new SqoopException(
|
||||||
@ -267,11 +265,12 @@ private synchronized void configureClassLoader(String classpathProperty) {
|
|||||||
|
|
||||||
private synchronized void configureLogging() {
|
private synchronized void configureLogging() {
|
||||||
Properties props = new Properties();
|
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)) {
|
if (key.startsWith(ConfigurationConstants.PREFIX_LOG_CONFIG)) {
|
||||||
String logConfigKey = key.substring(
|
String logConfigKey = key.substring(
|
||||||
ConfigurationConstants.PREFIX_GLOBAL_CONFIG.length());
|
ConfigurationConstants.PREFIX_GLOBAL_CONFIG.length());
|
||||||
props.put(logConfigKey, config.get(key));
|
props.put(logConfigKey, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user