TSK-767: setting UTF-8 explicitly while reading sample data

This commit is contained in:
Holger Hagen 2019-01-05 13:29:37 +01:00
parent 23d8d900cc
commit bcbd85c2e1
2 changed files with 11 additions and 14 deletions

View File

@ -103,12 +103,6 @@
<artifactId>spring-ldap-core</artifactId> <artifactId>spring-ldap-core</artifactId>
<version>${spring.ldap.version}</version> <version>${spring.ldap.version}</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>

View File

@ -59,15 +59,17 @@ public class SampleDataGenerator {
} }
/** /**
* This method resolves the custom sql function defined through this regex: {@value RELATIVE_DATE_REGEX}. * This method resolves the custom sql function defined through this regex: {@value RELATIVE_DATE_REGEX}. Its
* Its parameter is a digit representing the relative offset of a given starting point date. * parameter is a digit representing the relative offset of a given starting point date.
* <p/> * <p/>
* Yes, this can be done as an actual sql function, but that'd lead to a little more complexity * Yes, this can be done as an actual sql function, but that'd lead to a little more complexity (and thus we'd have
* (and thus we'd have to maintain the code for db compatibility ...) * to maintain the code for db compatibility ...) Since we're already replacing the boolean attributes of sql files
* Since we're already replacing the boolean attributes of sql files this addition is not a huge computational cost. * this addition is not a huge computational cost.
* *
* @param now anchor for relative date conversion. * @param now
* @param sql sql statement which may contain the above declared custom function. * anchor for relative date conversion.
* @param sql
* sql statement which may contain the above declared custom function.
* @return sql statement with the given function resolved, if the 'sql' parameter contained any. * @return sql statement with the given function resolved, if the 'sql' parameter contained any.
*/ */
private static String replaceRelativeTimeFunction(LocalDateTime now, String sql) { private static String replaceRelativeTimeFunction(LocalDateTime now, String sql) {
@ -82,7 +84,8 @@ public class SampleDataGenerator {
} }
private static String parseAndReplace(LocalDateTime now, InputStream stream) { private static String parseAndReplace(LocalDateTime now, InputStream stream) {
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream))) { try (
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
return replaceRelativeTimeFunction(now, return replaceRelativeTimeFunction(now,
bufferedReader.lines().collect(Collectors.joining(System.lineSeparator()))); bufferedReader.lines().collect(Collectors.joining(System.lineSeparator())));
} catch (IOException e) { } catch (IOException e) {