From 29eb1ae058145e21429ce4e73fa71d90c0d266bf Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Mon, 20 Oct 2014 17:51:15 +0100 Subject: [PATCH] HCOLL-167 made custom runtime exceptions visible --- .../exceptions/IORuntimeException.java | 13 ++++++++ .../exceptions/TimeoutRuntimeException.java | 9 ++++++ .../chronicle/map/StatelessChronicleMap.java | 30 +++---------------- 3 files changed, 26 insertions(+), 26 deletions(-) create mode 100644 src/main/java/net/openhft/chronicle/exceptions/IORuntimeException.java create mode 100644 src/main/java/net/openhft/chronicle/exceptions/TimeoutRuntimeException.java diff --git a/src/main/java/net/openhft/chronicle/exceptions/IORuntimeException.java b/src/main/java/net/openhft/chronicle/exceptions/IORuntimeException.java new file mode 100644 index 000000000..0084700bc --- /dev/null +++ b/src/main/java/net/openhft/chronicle/exceptions/IORuntimeException.java @@ -0,0 +1,13 @@ +package net.openhft.chronicle.exceptions; + +import java.io.IOException; + +/** + * @author Rob Austin. + */ +public class IORuntimeException extends RuntimeException{ + + public IORuntimeException(IOException e) { + super(e); + } +} diff --git a/src/main/java/net/openhft/chronicle/exceptions/TimeoutRuntimeException.java b/src/main/java/net/openhft/chronicle/exceptions/TimeoutRuntimeException.java new file mode 100644 index 000000000..25ea70985 --- /dev/null +++ b/src/main/java/net/openhft/chronicle/exceptions/TimeoutRuntimeException.java @@ -0,0 +1,9 @@ +package net.openhft.chronicle.exceptions; + +/** + * @author Rob Austin. + */ +public class TimeoutRuntimeException extends RuntimeException { + + +} diff --git a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java index 46c3b0d77..b04d97f37 100644 --- a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java @@ -1,6 +1,8 @@ package net.openhft.chronicle.map; import net.openhft.chronicle.StatelessBuilder; +import net.openhft.chronicle.exceptions.IORuntimeException; +import net.openhft.chronicle.exceptions.TimeoutRuntimeException; import net.openhft.lang.io.ByteBufferBytes; import net.openhft.lang.io.Bytes; import org.jetbrains.annotations.NotNull; @@ -392,7 +394,7 @@ class StatelessChronicleMap implements ChronicleMap, Closeable { return blockingFetchThrowable(sizeLocation, this.builder.timeoutMs()); } catch (IOException e) { closeables.closeQuietly(); - throw new RuntimeIOException(e); + throw new IORuntimeException(e); } catch (Exception e) { closeables.closeQuietly(); throw e; @@ -459,7 +461,7 @@ class StatelessChronicleMap implements ChronicleMap, Closeable { private void checkTimeout(long timeoutTime) { if (timeoutTime < System.currentTimeMillis()) - throw new TimeoutException(); + throw new TimeoutRuntimeException(); } private void writeSizeAt(long locationOfSize) { @@ -485,7 +487,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable { keyValueSerializer.writeValue(value, out); } - private Set readKeySet(Bytes in) { long size = in.readStopBit(); final HashSet result = new HashSet<>(); @@ -498,26 +499,3 @@ class StatelessChronicleMap implements ChronicleMap, Closeable { } - -interface Buffer { - - void set(ByteBufferBytes source); - - ByteBufferBytes get(); -} - -class RuntimeIOException extends RuntimeException { - - RuntimeIOException(IOException e) { - super(e); - } - -} - -class TimeoutException extends RuntimeException { - - TimeoutException() { - - } - -} \ No newline at end of file