Skip to content

Commit 3cf3964

Browse files
jonfreedmanchrjohn
authored andcommitted
Pass SessionID to MemoryStore constructor from MemoryStoreFactory (#161)
* pass SessionID to MemoryStore on construction * Update MemoryStore.java * fix for NPE on session lookup which causes test failures
1 parent d4b36c0 commit 3cf3964

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

quickfixj-core/src/main/java/quickfix/MemoryStore.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ public MemoryStore() throws IOException {
4343
reset();
4444
}
4545

46-
public MemoryStore(SessionID sessionID) {
46+
public MemoryStore(SessionID sessionID) throws IOException {
4747
this.sessionID = sessionID;
48+
reset();
4849
}
4950

5051
public void get(int startSequence, int endSequence, Collection<String> messages) throws IOException {
@@ -111,8 +112,8 @@ public void setNextTargetMsgSeqNum(int next) throws IOException {
111112
public void refresh() throws IOException {
112113
// IOException is declared to maintain strict compatibility with QF JNI
113114
final String text = "memory store does not support refresh!";
114-
if (sessionID != null) {
115-
Session session = Session.lookupSession(sessionID);
115+
final Session session = sessionID != null ? Session.lookupSession(sessionID) : null;
116+
if (session != null) {
116117
session.getLog().onErrorEvent("ERROR: " + text);
117118
} else {
118119
LoggerFactory.getLogger(MemoryStore.class).error(text);

quickfixj-core/src/main/java/quickfix/MemoryStoreFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class MemoryStoreFactory implements MessageStoreFactory {
3030

3131
public MessageStore create(SessionID sessionID) {
3232
try {
33-
return new MemoryStore();
33+
return new MemoryStore(sessionID);
3434
} catch (IOException e) {
3535
throw new RuntimeError(e);
3636
}

0 commit comments

Comments
 (0)