lsalamon / nhin-d

Automatically exported from code.google.com/p/nhin-d
0 stars 0 forks source link

XDR Web Service is picking up multiple recipients from previous messages on the same thread #249

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Send to XDR Endpoint multiple times

* Please note: the bug will only happen for multiple messages on the same 
thread. As new threads are managed this bug will not happen to everyone

What is the expected output? What do you see instead?

* Expected output: all SMTP messages coming from the XDR endpoint should have 
only the recipients (To:) indicated by the XDR message

* Actual output: for some message that are processed by the same thread for as 
previous XDR messages, multiple recipients are being picked up from the 
previous messages. The recipients are being appended to the recipient list.

What version of the product are you using?

* xd-common 1.1

Please provide any additional information below.

Related: http://www.directtrust.org/java-security-update/

Related Commit: 
https://code.google.com/p/nhin-d/source/detail?r=e1ce83e6e98a07fdecbf7118a884dfa
a553de66c

File: 

* DirectSOAPHandler.java
* 
https://code.google.com/p/nhin-d/source/browse/java/xd-common/src/main/java/org/
nhindirect/xd/soap/DirectSOAPHandler.java

Original issue reported on code.google.com by marc...@mirthcorp.com on 20 Nov 2014 at 4:41

GoogleCodeExporter commented 9 years ago
The issue was the DirectSOAPHandler was not clearing previous thread data 
appropriately. Our solution fixes this, by clearing out the thread data in 
handler for new inbound messages. Most of the thread data is overwritten by 
setters, but for the recipients (To) the thread data is appended to if not 
null. Lines 299 - 310 show this:

https://code.google.com/p/nhin-d/source/browse/java/xd-common/src/main/java/org/
nhindirect/xd/soap/DirectSOAPHandler.java?spec=svnabb446dfe7661e682afd68956c2412
19c996a2e0&r=e1ce83e6e98a07fdecbf7118a884dfaa553de66c#299

Our patch is on this class/method:

org.nhindirect.xd.soap.DirectSOAPHandler.handleMessage(SOAPMessageContext)

Just below the log of the inbound message, we add a clear:

                LOGGER.info("Handling an inbound message");

                // XDR-MULTIPLE-RECIPIENT-ISSUE - before handling the inbound case, we should clear 
                // out the old thread data if we don't this the To: (SMTP recipients) will 
                // append from the previous thread data 
                SafeThreadData.clean(Thread.currentThread().getId());

Original comment by marc...@mirthcorp.com on 20 Nov 2014 at 4:57

Attachments:

GoogleCodeExporter commented 9 years ago
Just to demonstrate this via a message flow:

Let's say we have a single thread processing back to back messages. Let's call 
this Thread-123 and that thread is brand new thread. 

XDR message:

  * Message 1

    * From: sender@foo.com
    * To: recipient@foo.com

  * Message 2
    * From: sender@bar.com
    * To: recipient@bar.com

SMTP out:

  * Message 1
    * From: sender@foo.com
    * To: recipient@foo.com

  * Message 2
    * From: sender@bar.com
    * To: recipient@foo.com
    * To: recipient@bar.com

The issue is not with handling of multiple recipients, but rather, the thread 
data is not being cleared out from message to message.

Original comment by marc...@mirthcorp.com on 20 Nov 2014 at 6:52

GoogleCodeExporter commented 9 years ago

Original comment by marc...@mirthcorp.com on 20 Nov 2014 at 6:52