fixed an issue, around sending exceptions back to the stateless client from the server

This commit is contained in:
Rob Austin
2015-05-14 10:50:09 +01:00
parent 549c499211
commit d48b683eed
2 changed files with 31 additions and 2 deletions
@@ -1818,12 +1818,16 @@ class StatelessServerConnector<K, V> {
@Nullable
private Work sendException(@NotNull TcpReplicator.TcpSocketChannelEntryWriter writer,
long sizeLocation, @NotNull Throwable e) {
LOG.error("cause by remote stateless client call", e);
// move the position to ignore any bytes written so far
writer.in().position(sizeLocation + HEADER_SIZE);
writeException(writer, e);
writeSizeAndFlags(sizeLocation + SIZE_OF_TRANSACTION_ID, true, writer.in());
writeSizeAndFlags(sizeLocation, true, writer.in());
return null;
}
@@ -26,7 +26,6 @@ import net.openhft.lang.io.ByteBufferBytes;
import net.openhft.lang.io.Bytes;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -208,6 +207,32 @@ public class StatelessClientTest {
}
@Test(timeout = 10000)
public void testLotsOfPuts() throws IOException, InterruptedException {
int port = s_port++;
final int size = 10000;
try (ChronicleMap<Integer, CharSequence> serverMap = ChronicleMapBuilder
.of(Integer.class, CharSequence.class)
.entries(100)
.replication((byte) 2, TcpTransportAndNetworkConfig.of(port))
.create()) {
try (ChronicleMap<Integer, CharSequence> statelessMap = localClient(port)) {
for (int i = 0; i < size; i++) {
statelessMap.put(i, "hello");
}
assertEquals(statelessMap.size(), size);
}
}
}
@Test
public void testBufferOverFlowPutAllAndKeySet() throws IOException, InterruptedException {
int port = 10 + s_port++;