From b34852cfcfaac47adea0300220e8b52e8c6b8fc1 Mon Sep 17 00:00:00 2001 From: terrymanu Date: Wed, 6 Apr 2016 16:56:29 +0800 Subject: [PATCH] fix #48 --- .../sharding/config/yaml/api/YamlShardingDataSource.java | 7 ++++++- sharding-jdbc-doc/content/post/release_notes.md | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sharding-jdbc-config-parent/sharding-jdbc-config-yaml/src/main/java/com/dangdang/ddframe/rdb/sharding/config/yaml/api/YamlShardingDataSource.java b/sharding-jdbc-config-parent/sharding-jdbc-config-yaml/src/main/java/com/dangdang/ddframe/rdb/sharding/config/yaml/api/YamlShardingDataSource.java index 7a27610f69b56..e79045a10030e 100644 --- a/sharding-jdbc-config-parent/sharding-jdbc-config-yaml/src/main/java/com/dangdang/ddframe/rdb/sharding/config/yaml/api/YamlShardingDataSource.java +++ b/sharding-jdbc-config-parent/sharding-jdbc-config-yaml/src/main/java/com/dangdang/ddframe/rdb/sharding/config/yaml/api/YamlShardingDataSource.java @@ -46,6 +46,11 @@ public YamlShardingDataSource(final Map dataSource, final Fi } private static YamlConfig unmarshal(final File yamlFile) throws IOException { - return new Yaml(new Constructor(YamlConfig.class)).loadAs(new InputStreamReader(new FileInputStream(yamlFile), "UTF-8"), YamlConfig.class); + try ( + FileInputStream fileInputStream = new FileInputStream(yamlFile); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8") + ) { + return new Yaml(new Constructor(YamlConfig.class)).loadAs(inputStreamReader, YamlConfig.class); + } } } diff --git a/sharding-jdbc-doc/content/post/release_notes.md b/sharding-jdbc-doc/content/post/release_notes.md index f560275052828..571bbf0afdf8a 100644 --- a/sharding-jdbc-doc/content/post/release_notes.md +++ b/sharding-jdbc-doc/content/post/release_notes.md @@ -6,11 +6,12 @@ weight = 1 # Release Notes -## 1.1.0-SNAPSHOT +## 1.1.1-SNAPSHOT ### 缺陷修正: 1. [ISSUE #43](https://github.com/dangdangdotcom/sharding-jdbc/issues/43) yaml文件中包含中文,且操作系统模式不是utf-8编码导致的yaml不能解析 +1. [ISSUE #48](https://github.com/dangdangdotcom/sharding-jdbc/issues/48) yaml文件读取后未关闭 ## 1.1.0