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

Commit 6090d54

Browse files
committed
Improving RequestScopeTest.
Change-Id: I9d4297f10f9c74bef7e038a0f93675cee4670f7d
1 parent 3e4842e commit 6090d54

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/RequestScopeTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040

4141
package org.glassfish.jersey.tests.e2e.common;
4242

43+
import java.util.concurrent.CountDownLatch;
44+
import java.util.concurrent.TimeUnit;
45+
4346
import javax.ws.rs.GET;
4447
import javax.ws.rs.Path;
4548
import javax.ws.rs.core.Application;
@@ -86,7 +89,7 @@ public interface CloseMe {
8689

8790
public static class CloseMeFactory implements Factory<CloseMe> {
8891

89-
public static volatile boolean closed = false;
92+
private static final CountDownLatch CLOSED_LATCH = new CountDownLatch(1);
9093

9194
@Override
9295
public CloseMe provide() {
@@ -98,7 +101,7 @@ public String eval() {
98101

99102
@Override
100103
public void close() {
101-
closed = true;
104+
CLOSED_LATCH.countDown();
102105
}
103106
};
104107
}
@@ -135,6 +138,6 @@ public void testRemove() throws Exception {
135138
assertThat(response.getStatus(), is(200));
136139
assertThat(response.readEntity(String.class), is("foo"));
137140

138-
assertTrue(CloseMeFactory.closed);
141+
assertTrue(CloseMeFactory.CLOSED_LATCH.await(3, TimeUnit.SECONDS));
139142
}
140143
}

0 commit comments

Comments
 (0)