From 54bb7e32887398d027f899a37853cd08f66edb3a Mon Sep 17 00:00:00 2001 From: charlesbr1 Date: Thu, 30 Jul 2015 00:16:54 -0500 Subject: [PATCH 1/3] Send fix message before logging it Do not wait for the logger to perform its task before sending a message. Avoid printing the fix message to send two time in case of error (no responder). Removed the synchronization as it is contention prone, and not really needed : it should not really prevent synch issue with either setResponder(...) or disconnect(...) methods. --- .../src/main/java/quickfix/Session.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/quickfixj-core/src/main/java/quickfix/Session.java b/quickfixj-core/src/main/java/quickfix/Session.java index c28e891a3c..f01315f4c2 100644 --- a/quickfixj-core/src/main/java/quickfix/Session.java +++ b/quickfixj-core/src/main/java/quickfix/Session.java @@ -2512,16 +2512,17 @@ public boolean send(Message message) { } private boolean send(String messageString) { - getLog().onOutgoing(messageString); - Responder responder; - synchronized (responderLock) { - responder = this.responder; - } - if (responder == null) { - getLog().onEvent("No responder, not sending message: " + messageString); + Responder responder = this.responder; + if(null == responder) { + this.getLog().onEvent("No responder, not sending message: " + messageString); return false; + } else { + try { + return responder.send(messageString); + } finally { + getLog().onOutgoing(messageString); + } } - return responder.send(messageString); } private boolean isCorrectCompID(Message message) throws FieldNotFound { From 820e604a5163bc85ae276d644fda85f5f6e5cf57 Mon Sep 17 00:00:00 2001 From: Charles Briquel Date: Thu, 24 Sep 2015 03:41:12 +0200 Subject: [PATCH 2/3] Update Session.java --- quickfixj-core/src/main/java/quickfix/Session.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickfixj-core/src/main/java/quickfix/Session.java b/quickfixj-core/src/main/java/quickfix/Session.java index f01315f4c2..73fd6bd32b 100644 --- a/quickfixj-core/src/main/java/quickfix/Session.java +++ b/quickfixj-core/src/main/java/quickfix/Session.java @@ -349,7 +349,7 @@ public class Session implements Closeable { private final Object responderLock = new Object(); // unique instance // @GuardedBy(responderLock) - private Responder responder; + private volatile Responder responder; // The session time checks were causing performance problems // so we are checking only once per second. @@ -2514,7 +2514,7 @@ public boolean send(Message message) { private boolean send(String messageString) { Responder responder = this.responder; if(null == responder) { - this.getLog().onEvent("No responder, not sending message: " + messageString); + getLog().onEvent("No responder, not sending message: " + messageString); return false; } else { try { From 01d4eaf72af903750d4d3e03f2db3b09b22e6cd4 Mon Sep 17 00:00:00 2001 From: Charles Briquel Date: Thu, 22 Oct 2015 16:11:09 +0200 Subject: [PATCH 3/3] Update Session.java better testing != null --- quickfixj-core/src/main/java/quickfix/Session.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/quickfixj-core/src/main/java/quickfix/Session.java b/quickfixj-core/src/main/java/quickfix/Session.java index 73fd6bd32b..ca1fed8791 100644 --- a/quickfixj-core/src/main/java/quickfix/Session.java +++ b/quickfixj-core/src/main/java/quickfix/Session.java @@ -2513,16 +2513,15 @@ public boolean send(Message message) { private boolean send(String messageString) { Responder responder = this.responder; - if(null == responder) { - getLog().onEvent("No responder, not sending message: " + messageString); - return false; - } else { + if(null != responder) { try { return responder.send(messageString); } finally { getLog().onOutgoing(messageString); } - } + } else + getLog().onEvent("No responder, not sending message: " + messageString); + return false; } private boolean isCorrectCompID(Message message) throws FieldNotFound {