mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-19 22:09:01 +00:00
Merge pull request #50369 from quaff
Closes gh-50369 * pr/50369: Polish AppendableByteArray
This commit is contained in:
+4
-2
@@ -25,6 +25,8 @@ import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -36,7 +38,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
class AppendableByteArray implements Appendable {
|
||||
|
||||
private static ThreadLocal<SoftReference<AppendableByteArray>> cache = new ThreadLocal<>();
|
||||
private static final ThreadLocal<@Nullable SoftReference<AppendableByteArray>> cache = new ThreadLocal<>();
|
||||
|
||||
private static final int DEFAULT_INITIAL_SIZE = 8192;
|
||||
|
||||
@@ -66,7 +68,7 @@ class AppendableByteArray implements Appendable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppendableByteArray append(CharSequence charSequence, int start, int end) throws IOException {
|
||||
public AppendableByteArray append(@Nullable CharSequence charSequence, int start, int end) throws IOException {
|
||||
return append(((charSequence != null) ? charSequence : "null").subSequence(start, end));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class AppendableByteArrayTests {
|
||||
|
||||
private static String string = """
|
||||
private static final String string = """
|
||||
This is a long(ish) string.
|
||||
At least it's longer that the initial size and the overflow size.
|
||||
We can write it out and test if the bytes match.
|
||||
|
||||
Reference in New Issue
Block a user