TSK-987: Fix Spotbugs - reliance on default encoding
This commit is contained in:
parent
faf6065c48
commit
4d560532bd
|
@ -4,6 +4,7 @@ import java.io.InputStreamReader;
|
|||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import javax.sql.DataSource;
|
||||
|
@ -31,7 +32,9 @@ public class DbWriter {
|
|||
ScriptRunner runner = null;
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
runner = configScriptRunner(connection);
|
||||
runner.runScript(new InputStreamReader(DbWriter.class.getResourceAsStream(INSERTVALUES)));
|
||||
runner.runScript(
|
||||
new InputStreamReader(
|
||||
DbWriter.class.getResourceAsStream(INSERTVALUES), StandardCharsets.UTF_8));
|
||||
} finally {
|
||||
LOGGER.debug(outWriter.toString());
|
||||
if (!errorWriter.toString().trim().isEmpty()) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
|
||||
|
@ -86,11 +87,11 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
|
|||
subsectionWithPath("classifications")
|
||||
.description("An Array of <<classification-subset, Classification-Subsets>>"),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page").ignored(),
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored()
|
||||
fieldWithPath("page").ignored(),
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored()
|
||||
};
|
||||
|
||||
classificationFieldDescriptors =
|
||||
|
@ -334,7 +335,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
|
|||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
|
||||
|
@ -53,7 +54,7 @@ class ClassificationDefinitionControllerRestDocumentation extends BaseRestDocume
|
|||
this.mockMvc
|
||||
.perform(
|
||||
multipart(restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION))
|
||||
.file("file", definitionString.getBytes())
|
||||
.file("file", definitionString.getBytes(UTF_8))
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
|
||||
|
@ -111,11 +112,11 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
fieldWithPath("_links").ignored(),
|
||||
fieldWithPath("_links.self").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page").ignored(),
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored()
|
||||
fieldWithPath("page").ignored(),
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored()
|
||||
};
|
||||
|
||||
taskFieldDescriptors =
|
||||
|
@ -518,7 +519,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
|
||||
String inputLine;
|
||||
StringBuilder content = new StringBuilder();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
|
||||
|
@ -454,7 +455,7 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
|
|||
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
|
||||
|
@ -61,7 +62,7 @@ class WorkbasketDefinitionControllerRestDocumentation extends BaseRestDocumentat
|
|||
this.mockMvc
|
||||
.perform(
|
||||
multipart(restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS))
|
||||
.file("file", definitionString.getBytes())
|
||||
.file("file", definitionString.getBytes(UTF_8))
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
@ -289,7 +290,7 @@ class TaskControllerIntTest {
|
|||
assertEquals(200, con.getResponseCode());
|
||||
final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
|
@ -312,7 +313,7 @@ class TaskControllerIntTest {
|
|||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
|
@ -327,7 +328,7 @@ class TaskControllerIntTest {
|
|||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream(), UTF_8));
|
||||
out.write(content.toString());
|
||||
out.flush();
|
||||
out.close();
|
||||
|
@ -340,7 +341,7 @@ class TaskControllerIntTest {
|
|||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
|
||||
content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
|
@ -420,7 +421,7 @@ class TaskControllerIntTest {
|
|||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream(), UTF_8));
|
||||
out.write(taskToCreateJson);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
@ -440,7 +441,7 @@ class TaskControllerIntTest {
|
|||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
|
||||
out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream(), UTF_8));
|
||||
out.write(taskToCreateJson2);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -9,8 +10,9 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
@ -161,7 +163,7 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
private ResponseEntity<Void> importRequest(List<String> clList) throws IOException {
|
||||
File tmpFile = File.createTempFile("test", ".tmp");
|
||||
FileWriter writer = new FileWriter(tmpFile);
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmpFile), UTF_8);
|
||||
writer.write(clList.toString());
|
||||
writer.close();
|
||||
|
||||
|
|
Loading…
Reference in New Issue