[QFJ-642] SessionSettings getSessionProperties(Foo, true) merges the actual settings into the defaults Created: 17/Oct/11 Updated: 15/Nov/12 Resolved: 19/Oct/11 |
|
Status: | Closed |
Project: | QuickFIX/J |
Component/s: | Engine |
Affects Version/s: | 1.5.0, 1.5.1 |
Fix Version/s: | 1.5.2 |
Type: | Bug | Priority: | Major |
Reporter: | Mate Varga | Assignee: | Laurent Danesi |
Resolution: | Fixed | Votes: | 0 |
Labels: | None |
Description |
If you do the following in your code: Properties sessionProperties = sessionSettings.getSessionProperties(sessionID, true); Then after executing the previous statement, sessionSettings.getDefaultProperties() will return the original default properties MERGED WITH the session properties specified under the sessionID, which is completely wrong. The reason lies in SessionSettings.java (comments inlined): public Properties getSessionProperties(SessionID sessionID, boolean includeDefaults) throws ConfigError { if (includeDefaults) { final Properties mergedProperties = sections.get(DEFAULT_SESSION_ID); // THIS RETURNS A REFERENCE, NOT A COPY!! mergedProperties.putAll(p); /// THAT IS COMPLETELY WRONG, AS THIS MODIFIES THE ORIGINAL MAP CONTENTS return mergedProperties; }else { return p; }} The proper solution would be to create a new Properties object and initialise it using the Properties object returned by sections.get(). |
Comments |
Comment by Mate Varga [ 18/Oct/11 ] |
// Fix: public Properties getSessionProperties(SessionID sessionID, boolean includeDefaults) throws ConfigError { |
Comment by Laurent Danesi [ 19/Oct/11 ] |
committed rev #1054 |