ensure that we close() on interupt

This commit is contained in:
Rob Austin
2015-02-02 22:05:32 +00:00
parent 357803e0df
commit 5f627dc6b4
2 changed files with 18 additions and 14 deletions
@@ -257,7 +257,9 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
LOG.debug("onWrite - " + name);
onWrite(key, approxTime);
}
} catch (BufferUnderflowException | InterruptedException | IOException |
} catch (InterruptedException e) {
quietClose(key, e);
} catch (BufferUnderflowException | IOException |
ClosedSelectorException | CancelledKeyException e) {
if (!isClosed)
quietClose(key, e);
@@ -355,25 +355,27 @@ public class CHMUseCasesTest {
@Ignore
@Test
public void testByteArrayArrayValue() throws ExecutionException, InterruptedException, IOException {
int valueSize = 10;
for (int i=0; i < 10000; i++) {
int valueSize = 10;
char[] expected = new char[valueSize];
Arrays.fill(expected, 'X');
char[] expected = new char[valueSize];
Arrays.fill(expected, 'X');
ChronicleMapBuilder<byte[], byte[][]> builder = ChronicleMapBuilder
.of(byte[].class, byte[][].class);
ChronicleMapBuilder<byte[], byte[][]> builder = ChronicleMapBuilder
.of(byte[].class, byte[][].class);
try (ChronicleMap<byte[], byte[][]> map = newInstance(builder)) {
byte[] bytes1 = "value1".getBytes();
byte[] bytes2 = "value2".getBytes();
byte[][] value = {bytes1, bytes2};
map.put("Key".getBytes(), value);
try (ChronicleMap<byte[], byte[][]> map = newInstance(builder)) {
byte[] bytes1 = "value1".getBytes();
byte[] bytes2 = "value2".getBytes();
byte[][] value = {bytes1, bytes2};
map.put("Key".getBytes(), value);
assertEquals(value, map.get("Key".getBytes()));
mapChecks();
assertEquals(value, map.get("Key".getBytes()));
mapChecks();
}
}
}