Commit 1d8bc9b1 authored by afreyssin's avatar afreyssin

Workaround for an issue with reliable connection, a duplicate message should...

Workaround for an issue with reliable connection, a duplicate message should never occur (JORAM-287). Throws an exception, then closes the connection.
parent 4ea6e783
/* /*
* Copyright (C) 2004 - 2013 ScalAgent Distributed Technologies * Copyright (C) 2004 - 2018 ScalAgent Distributed Technologies
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -161,11 +161,10 @@ public class ReliableTcpConnection { ...@@ -161,11 +161,10 @@ public class ReliableTcpConnection {
if (getStatus() != CONNECT) if (getStatus() != CONNECT)
throw new IOException("Connection closed"); throw new IOException("Connection closed");
try { try {
synchronized (outputLock) { synchronized (outputLock) {
doSend(outputCounter, inputCounter, request); doSend(outputCounter, inputCounter, request);
if (!noAckedQueue) { if (!noAckedQueue) {
addPendingMessage(new TcpMessage( addPendingMessage(new TcpMessage(outputCounter, request));
outputCounter, request));
} }
outputCounter++; outputCounter++;
} }
...@@ -277,6 +276,7 @@ public class ReliableTcpConnection { ...@@ -277,6 +276,7 @@ public class ReliableTcpConnection {
if (logger.isLoggable(BasicLevel.DEBUG)) if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, " -> id = " + messageId); logger.log(BasicLevel.DEBUG, " -> id = " + messageId);
if (!noAckedQueue) { if (!noAckedQueue) {
ackPendingMessages(ackId); ackPendingMessages(ackId);
if (obj != null) { if (obj != null) {
...@@ -293,9 +293,11 @@ public class ReliableTcpConnection { ...@@ -293,9 +293,11 @@ public class ReliableTcpConnection {
if (messageId > inputCounter) { if (messageId > inputCounter) {
inputCounter = messageId; inputCounter = messageId;
return obj; return obj;
} else if (logger.isLoggable(BasicLevel.DEBUG)) } else {
logger.log(BasicLevel.DEBUG, logger.log(BasicLevel.WARN, " -> already received message: " + messageId + " " + obj);
" -> already received message: " + messageId + " " + obj); // This should never happened, close the connection.
throw new IOException("Duplicate message: " + messageId);
}
} }
} else { } else {
if (obj != null) { if (obj != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment