Replace hardcoded charsets with StandardCharsets
This commit is contained in:
@@ -354,7 +354,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
|
||||
|
||||
try {
|
||||
serializer.serialize(m, out);
|
||||
results = new String(out.toByteArray(), charset.name());
|
||||
results = out.toString(charset);
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
throw new IllegalArgumentException("Could not serialize the execution context", ioe);
|
||||
@@ -374,7 +374,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
|
||||
|
||||
Map<String, Object> map;
|
||||
try {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(serializedContext.getBytes(charset.name()));
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(serializedContext.getBytes(charset));
|
||||
map = serializer.deserialize(in);
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.batch.support.transaction;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -41,6 +42,7 @@ import static org.mockito.Mockito.when;
|
||||
* @author Michael Minella
|
||||
* @author Will Schipp
|
||||
* @author Niels Ferguson
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
class TransactionAwareBufferedWriterTests {
|
||||
@@ -301,7 +303,7 @@ class TransactionAwareBufferedWriterTests {
|
||||
FileChannel fileChannel = mock(FileChannel.class);
|
||||
when(fileChannel.write(any(ByteBuffer.class))).thenAnswer(invocation -> {
|
||||
ByteBuffer buffer = (ByteBuffer) invocation.getArguments()[0];
|
||||
String val = new String(buffer.array(), "UTF-8");
|
||||
String val = new String(buffer.array(), StandardCharsets.UTF_8);
|
||||
if (results[index] == null) {
|
||||
results[index] = val;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -45,8 +47,9 @@ class MultilineJobFunctionalTests {
|
||||
@Test
|
||||
void testJobLaunch() throws Exception {
|
||||
this.jobLauncherTestUtils.launchJob();
|
||||
assertEquals(EXPECTED_RESULT, StringUtils.replace(IOUtils.toString(output.getInputStream(), "UTF-8"),
|
||||
System.getProperty("line.separator"), ""));
|
||||
assertEquals(EXPECTED_RESULT,
|
||||
StringUtils.replace(IOUtils.toString(output.getInputStream(), StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"), ""));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user