This commit is contained in:
hxy1991 2019-04-01 11:48:53 +08:00
parent b1790fa09e
commit 9c9050207e

View File

@ -16,6 +16,7 @@
package com.alibaba.nacos.core.utils; package com.alibaba.nacos.core.utils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -34,8 +35,8 @@ public class PropertyUtil {
private static final Logger log = LoggerFactory.getLogger(PropertyUtil.class); private static final Logger log = LoggerFactory.getLogger(PropertyUtil.class);
static { static {
InputStream inputStream = null;
try { try {
InputStream inputStream = null;
String baseDir = System.getProperty("nacos.home"); String baseDir = System.getProperty("nacos.home");
if (!StringUtils.isBlank(baseDir)) { if (!StringUtils.isBlank(baseDir)) {
inputStream = new FileInputStream(baseDir + "/conf/application.properties"); inputStream = new FileInputStream(baseDir + "/conf/application.properties");
@ -46,6 +47,8 @@ public class PropertyUtil {
properties.load(inputStream); properties.load(inputStream);
} catch (Exception e) { } catch (Exception e) {
log.error("read property file error:" + e); log.error("read property file error:" + e);
} finally {
IOUtils.closeQuietly(inputStream);
} }
} }