Skip to main content

OutputPipe.send question

1 reply [Last post]
iiggoorr
Offline
Joined: 2008-09-22

Hi,

I found warning in java doc for send method of OutputPipe i quote:
"The message object used when sending a pipe message should not be reused or modified after the send(Message) call is made. Concurrent modification of messages will produce unexpected result. "

What does it really mean, when can i reuse Message object for sending new message?
I mean don't spouse that i need 100 different instances of Message to send 100 messages?

Just for clarification, I am sending messages only in one thread, so there is no possibility that one Thread is sending and the other is changing same Message instance.

THX

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
adamman71
Offline
Joined: 2007-01-31

Hi,

The message you send is an XML doc. As part of sending that message, JXTA may add information to it, such as source and destination information. JXTA is a bit lazy and does not clone the message passed in parameter. It uses the one it received and modifies it as necessary.

Hence, you should not reuse that message after sending it. If you need to, clone it before sending it.

If that message is not accessed in any way by other threads, it won't be concurrently modified by JXTA itself.

Cheers,

J.