Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 8482c71

Browse files
committed
Small improvement in ChunkedOutput flushing.
Change-Id: I78fc289ac0d8a9797f5513b46801beb9ef582324
1 parent e6ca2a3 commit 8482c71

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core-server/src/main/java/org/glassfish/jersey/server/ChunkedOutput.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.util.concurrent.BlockingDeque;
4848
import java.util.concurrent.Callable;
4949
import java.util.concurrent.LinkedBlockingDeque;
50+
import java.util.concurrent.atomic.AtomicBoolean;
5051

5152
import javax.ws.rs.container.ConnectionCallback;
5253
import javax.ws.rs.core.GenericType;
@@ -74,11 +75,11 @@ public class ChunkedOutput<T> extends GenericType<T> implements Closeable {
7475

7576
private final BlockingDeque<T> queue = new LinkedBlockingDeque<>();
7677
private final byte[] chunkDelimiter;
78+
private final AtomicBoolean resumed = new AtomicBoolean(false);
7779

7880
private boolean flushing = false;
7981

8082
private volatile boolean closed = false;
81-
private volatile boolean resumed = false;
8283

8384
private volatile AsyncContext asyncContext;
8485

@@ -204,8 +205,7 @@ public void write(final T chunk) throws IOException {
204205
}
205206

206207
protected void flushQueue() throws IOException {
207-
if (!resumed && asyncContext != null) {
208-
resumed = true;
208+
if (resumed.compareAndSet(false, true) && asyncContext != null) {
209209
asyncContext.resume(this);
210210
}
211211

0 commit comments

Comments
 (0)