Skip to content

Commit

Permalink
Fixed #521.
Browse files Browse the repository at this point in the history
  • Loading branch information
haocao committed Dec 27, 2017
1 parent 4bccaef commit 4f67c30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### 功能提升
1. [ISSUE #475](https://github.com/shardingjdbc/sharding-jdbc/issues/475) 支持create index语句

### 缺陷修正
1. [ISSUE #521](https://github.com/shardingjdbc/sharding-jdbc/issues/521) YAML文件中ShardingProperties设置无效

## 2.0.1

### 功能提升
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package io.shardingjdbc.core.constant;

import com.google.common.base.Strings;
import io.shardingjdbc.core.util.StringUtil;
import com.google.common.base.Joiner;

Expand Down Expand Up @@ -80,7 +81,15 @@ private String getErrorMessage(final ShardingPropertiesConstant shardingProperti
*/
@SuppressWarnings("unchecked")
public <T> T getValue(final ShardingPropertiesConstant shardingPropertiesConstant) {
String result = props.getProperty(shardingPropertiesConstant.getKey(), shardingPropertiesConstant.getDefaultValue());
String result = props.getProperty(shardingPropertiesConstant.getKey());
if (Strings.isNullOrEmpty(result)) {
Object obj = props.get(shardingPropertiesConstant.getKey());
if (null == obj) {
result = shardingPropertiesConstant.getDefaultValue();
} else {
result = obj.toString();
}
}
if (boolean.class == shardingPropertiesConstant.getType()) {
return (T) Boolean.valueOf(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.shardingjdbc.core.api.ConfigMapContext;
import io.shardingjdbc.core.api.ShardingDataSourceFactory;
import io.shardingjdbc.core.constant.ShardingProperties;
import io.shardingjdbc.core.constant.ShardingPropertiesConstant;
import io.shardingjdbc.core.yaml.AbstractYamlDataSourceTest;
import lombok.RequiredArgsConstructor;
import org.junit.Test;
Expand All @@ -44,6 +45,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertTrue;

@RunWith(Parameterized.class)
@RequiredArgsConstructor
Expand Down Expand Up @@ -83,7 +85,7 @@ public DataSource apply(final String key) {
field.setAccessible(true);
}
ShardingProperties shardingProperties = (ShardingProperties) field.get(dataSource);
//assertTrue((Boolean) shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW));
assertTrue((Boolean) shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW));
}
Map<String, Object> configMap = new ConcurrentHashMap<>();
configMap.put("key1", "value1");
Expand Down

0 comments on commit 4f67c30

Please sign in to comment.