fixed NPE - java.lang.NullPointerException

at net.openhft.chronicle.map.StatelessChronicleMap.receiveBytesFromSocket(StatelessChronicleMap.java:1322)
                at net.openhft.chronicle.map.StatelessChronicleMap.nextEntry(StatelessChronicleMap.java:1216)
                at net.openhft.chronicle.map.StatelessChronicleMap.blockingFetchThrowable(StatelessChronicleMap.java:1162)
                at net.openhft.chronicle.map.StatelessChronicleMap.blockingFetchReadOnly(StatelessChronicleMap.java:1135)
                at net.openhft.chronicle.map.StatelessChronicleMap.readValue(StatelessChronicleMap.java:1484)
                at net.openhft.chronicle.map.StatelessChronicleMap.fetchObject(StatelessChronicleMap.java:1782)
                at net.openhft.chronicle.map.StatelessChronicleMap.put(StatelessChronicleMap.java:596)
                at net.openhft.chronicle.map.StatelessClientTest$3.run(StatelessClientTest.java:659)
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
                at java.util.concurrent.FutureTask.run(FutureTask.java:262)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
                at java.lang.Thread.run(Thread.java:745)
This commit is contained in:
Rob Austin
2015-02-02 08:28:57 +00:00
parent c8476c1326
commit a6938caad4
@@ -81,7 +81,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
private final InetSocketAddress remoteAddress;
private final long timeoutMs;
private final int tcpBufferSize;
private Class<K> kClass;
private Class<V> vClass;
private boolean putReturnsNull;
@@ -376,7 +376,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
// read a single byte back
while (this.connectionOutBuffer.position() <= 0) {
int read = clientChannel.read(this.connectionOutBuffer);// the remote identifier
if (read ==-1)
if (read == -1)
throw new IOException("server conncetion closed");
checkTimeout(timeoutTime);
}
@@ -1308,6 +1308,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
@SuppressWarnings("UnusedReturnValue")
private Bytes receiveBytesFromSocket(int requiredNumberOfBytes, long timeoutTime) throws IOException {
// assert !outBytesLock.isHeldByCurrentThread();
assert inBytesLock.isHeldByCurrentThread();
@@ -1315,11 +1316,14 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
inBytes.limit(requiredNumberOfBytes);
inBytes.buffer().position(0);
inBytes.buffer().limit(requiredNumberOfBytes);
SocketChannel clientChannel0 = clientChannel;
if (clientChannel0 == null)
return inBytes;
while (inBytes.buffer().remaining() > 0) {
assert requiredNumberOfBytes <= inBytes.capacity();
int len = clientChannel.read(inBytes.buffer());
int len = clientChannel0.read(inBytes.buffer());
if (len == -1)
throw new IORuntimeException("Disconnection to server");