Skip to content

Commit 6f5b892

Browse files
committed
Fix spotless
1 parent 04bd1ef commit 6f5b892

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/ThreadLocalByteStringOutputStream.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.beam.runners.dataflow.worker.util;
1919

2020
import java.lang.ref.SoftReference;
21+
import java.util.Objects;
2122
import javax.annotation.concurrent.ThreadSafe;
2223
import org.apache.beam.sdk.annotations.Internal;
2324
import org.apache.beam.sdk.util.ByteStringOutputStream;
@@ -31,7 +32,7 @@
3132
*/
3233
public class ThreadLocalByteStringOutputStream {
3334

34-
private static final ThreadLocal<SoftRefHolder> threadLocalSoftRefHolder =
35+
private static final ThreadLocal<@Nullable SoftRefHolder> threadLocalSoftRefHolder =
3536
ThreadLocal.withInitial(SoftRefHolder::new);
3637

3738
// Private constructor to prevent instantiations from outside.
@@ -113,7 +114,9 @@ public static RefHolder create() {
113114
private static RefHolder getRefHolderFromThreadLocal() {
114115
SoftRefHolder softRefHolder = threadLocalSoftRefHolder.get();
115116
RefHolder refHolder;
116-
if (softRefHolder.softReference != null && softRefHolder.softReference.get() != null) {
117+
// softRefHolder is only set by Threadlocal initializer and should not be null
118+
if (Objects.requireNonNull(softRefHolder).softReference != null
119+
&& softRefHolder.softReference.get() != null) {
117120
refHolder = softRefHolder.softReference.get();
118121
} else {
119122
refHolder = RefHolder.create();

0 commit comments

Comments
 (0)