Skip to content

Commit

Permalink
Fix UTF-8 support in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrin committed Apr 10, 2020
1 parent 55f5fd2 commit c8546e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### v0.2.6

- Fix UTF-8 support in config files (ruuvi-collector.properties and ruuvi-names.properties). This might be a breaking change if your config relied on broken charset support.

### v0.2.5

- Improved error tolerance while parsing for raw data
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/fi/tkgwf/ruuvi/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -121,7 +123,7 @@ private static void readConfig() {
if (configFile != null) {
LOG.debug("Config: " + configFile);
Properties props = new Properties();
props.load(new FileInputStream(configFile));
props.load(new InputStreamReader(new FileInputStream(configFile), Charset.forName("UTF-8")));
readConfigFromProperties(props);
}
} catch (IOException ex) {
Expand Down Expand Up @@ -321,7 +323,7 @@ private static void readTagNames() {
if (configFile != null) {
LOG.debug("Tag names: " + configFile);
Properties props = new Properties();
props.load(new FileInputStream(configFile));
props.load(new InputStreamReader(new FileInputStream(configFile), Charset.forName("UTF-8")));
Enumeration<?> e = props.propertyNames();
while (e.hasMoreElements()) {
String key = StringUtils.trimToEmpty((String) e.nextElement()).toUpperCase();
Expand Down

0 comments on commit c8546e2

Please sign in to comment.