Replace hardcoded charsets with StandardCharsets
This commit is contained in:
@@ -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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -55,12 +55,7 @@ public class DefaultJobKeyGenerator implements JobKeyGenerator<JobParameters> {
|
||||
stringBuffer.append(key).append("=").append(value).append(";");
|
||||
}
|
||||
}
|
||||
try {
|
||||
return DigestUtils.md5DigestAsHex(stringBuffer.toString().getBytes("UTF-8"));
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("UTF-8 encoding not available. Fatal (should be in the JDK).");
|
||||
}
|
||||
return DigestUtils.md5DigestAsHex(stringBuffer.toString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.List;
|
||||
|
||||
@@ -74,7 +75,7 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
@Test
|
||||
void testHexing() throws Exception {
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
byte[] bytes = digest.digest("f78spx".getBytes("UTF-8"));
|
||||
byte[] bytes = digest.digest("f78spx".getBytes(StandardCharsets.UTF_8));
|
||||
StringBuilder output = new StringBuilder();
|
||||
for (byte bite : bytes) {
|
||||
output.append(String.format("%02x", bite));
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package test.jdbc.datasource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -102,7 +103,7 @@ public class DataSourceInitializer implements InitializingBean {
|
||||
String[] scripts;
|
||||
try {
|
||||
scripts = StringUtils.delimitedListToStringArray(
|
||||
stripComments(IOUtils.readLines(scriptResource.getInputStream(), "UTF-8")), ";");
|
||||
stripComments(IOUtils.readLines(scriptResource.getInputStream(), StandardCharsets.UTF_8)), ";");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BeanInitializationException("Cannot load script from [" + scriptResource + "]", e);
|
||||
|
||||
Reference in New Issue
Block a user