mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Use more specific ChronicleHashClosedException instead of IllegalStateException, when methods of ChronicleHash are called after hash.close(). Actualize ChronicleHash.close() javadoc.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.ChronicleHashClosedException;
|
||||
import net.openhft.chronicle.hash.impl.stage.hash.ChainingInterface;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -34,6 +35,38 @@ public class MapCloseTest {
|
||||
map.close();
|
||||
}
|
||||
|
||||
@Test(expected = ChronicleHashClosedException.class)
|
||||
public void testGetAfterCloseThrowsChronicleHashClosedException() throws InterruptedException {
|
||||
ChronicleMap<Integer, Integer> map =
|
||||
ChronicleMap.of(Integer.class, Integer.class).entries(1).create();
|
||||
Thread t = new Thread(() -> map.close());
|
||||
t.start();
|
||||
t.join();
|
||||
map.get(1);
|
||||
}
|
||||
|
||||
@Test(expected = ChronicleHashClosedException.class)
|
||||
public void testIterationAfterCloseThrowsChronicleHashClosedException()
|
||||
throws InterruptedException {
|
||||
ChronicleMap<Integer, Integer> map =
|
||||
ChronicleMap.of(Integer.class, Integer.class).entries(1).create();
|
||||
Thread t = new Thread(() -> map.close());
|
||||
t.start();
|
||||
t.join();
|
||||
map.forEach((k, v) -> {});
|
||||
}
|
||||
|
||||
@Test(expected = ChronicleHashClosedException.class)
|
||||
public void testSizeAfterCloseThrowsChronicleHashClosedException()
|
||||
throws InterruptedException {
|
||||
ChronicleMap<Integer, Integer> map =
|
||||
ChronicleMap.of(Integer.class, Integer.class).entries(1).create();
|
||||
Thread t = new Thread(() -> map.close());
|
||||
t.start();
|
||||
t.join();
|
||||
map.size();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void closeWithContextInAnotherThreadTest() throws InterruptedException {
|
||||
ChronicleMap<Integer, Integer> map =
|
||||
|
||||
Reference in New Issue
Block a user