kafelez / jsendnsca

Automatically exported from code.google.com/p/jsendnsca
0 stars 0 forks source link

MessagePayloadBuilder reuse same instance when building multiple messages #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
For example by testing and sending multiple messages to the NagiosNscaStub 
which you then 
want to iterate afterwards to check for correct order of messages. Then the 
number of messages 
is correct but the messages are all the same = the last message that 
MessagePayloadBuilder 
created.

The create method should prepare a new instance for next builder, but it doesnt 
so it end up 
overriding with data intended for next message

I have created a patch

    public static MessagePayload create() {
        MessagePayload answer = instance.payload;
        // create a new instance for builder to use next time otherwise we end up
        // changing the instance we just created
        instance = new MessagePayloadBuilder();
        return answer;
    }

Original issue reported on code.google.com by claus.ib...@gmail.com on 12 Jan 2010 at 3:49

GoogleCodeExporter commented 8 years ago
The patch with the fix including unit tests.

Also attached the unit test as individual files

Original comment by claus.ib...@gmail.com on 12 Jan 2010 at 3:51

Attachments:

GoogleCodeExporter commented 8 years ago
Looks like the patch was gone here it is

Original comment by claus.ib...@gmail.com on 12 Jan 2010 at 3:52

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Claus,

Thanks for taking the time to report this, 

Ive applied your patch and checked in on trunk

Currently planning release 2.0 so will release this fix as part of that release

Original comment by rajneeshpatel on 12 Jan 2010 at 6:55

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
To be now included in maintenance release 1.3

Original comment by rajneeshpatel on 13 Jan 2010 at 11:13

GoogleCodeExporter commented 8 years ago

Original comment by rajneeshpatel on 13 Jan 2010 at 11:15