ObjectOutputStream: Sending the same but modified Object twice

Using the Windows JRE1.6_05 or the JRE 1.6 on Mac OS X and the following code for the client:
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
public class Client {
     public static void main(String[] args) throws Exception {
          Socket s=new Socket("127.0.0.1",5000);
          ObjectOutputStream oos= new ObjectOutputStream(s.getOutputStream());
          StringBuffer sb=new StringBuffer("foo");
          oos.writeObject(sb);
          sb.replace(0, sb.length(), "bar");
          oos.writeObject(sb);
}and the following code for the server
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
     public static void main(String[] args) throws Exception {
          ServerSocket ss=new ServerSocket(5000);
          Socket s= ss.accept();
          ObjectInputStream ois= new ObjectInputStream(s.getInputStream());
          StringBuffer sb=(StringBuffer)ois.readObject();
          System.out.print(sb);
          sb=(StringBuffer)ois.readObject();
          System.out.println(" "+sb);
}I expect to get the output "foo bar" but getting "foo foo". For every object type it is true that the non-modified object is received, if the same but modified object is sent twice. Is this a bug?

burghard.britzke wrote:
The substitution of writeObject(obj) with writeUnshared(obj) on the client and readObject(obj) with readUnshared(obj) lead to the "foo foo", too.I always use reset() on the OOS.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            StringBuffer sb = new StringBuffer("foo");
            oos.reset();
            oos.writeObject(sb);
            sb.replace(0, sb.length(), "bar");
            oos.reset();
            oos.writeObject(sb);
            oos.close();
            ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
            StringBuffer sb = (StringBuffer) ois.readObject();
            System.out.print(sb);
            sb = (StringBuffer) ois.readObject();
            System.out.println(" " + sb);
        }

Similar Messages

  • A workflow is sending the same email notification twice

    A workflow is sending the same email notification twice. Not every notification, but this happening only a few times randomly.  The double sent emails are arriving together , have the same date and time.
    I've checked the workflow and found that there is no double sending command in the workflow, and the workflow history also shows just 1 run and 1 email sending.
    Can somebody help me on this.

    Hi Neel,
    For troubleshooting your issue, you can take steps as below:
    1.Increasing the UserDefinedWorkflowMaximumComplexity to 30000 setting using Powershell script
    2.IISRESET
    3.Adding <httpRuntime maxRequestLength="51200" executionTimeout="3600" /> in web.config. Yes, that is "3600" unlike "300" suggested. Please note that there are multiple lines in web.config with <httpRuntime maxRequestLength="51200">.
    I made this change only in the very first one.
    4.IISRESET
    5.Removed everything from C:\Users\<userName>\AppData\Local\Microsoft\WebsiteCache from my laptop
    6.Removed everything from C:\Users\<userName>\AppData\Roaming\Microsoft\Web Server Extensions\Cache from my laptop
    7.Removed everything from C:\Users\USER\AppData\Roaming\Microsoft\SharePoint Designer\ProxyAssemblyCache\ from my laptop
    8.IISRESET
    9.Restart SharePoint 2013 Designer
    Reference:
    https://social.msdn.microsoft.com/Forums/en-US/69b184bf-09ed-4e00-815a-4e40a975c4bf/prevent-sharepoint-2010-workflow-to-send-duplicate-emails?forum=sharepointcustomization
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Sending the same email message several times to contacts.  Turned off iCloud, but still sending message.

    Sending the same email message several times to contacts.  Turned off iCloud, but still sending message. 
    A user had synced all of his contacts from his computer and iPhone to his iCloud.  Today, his iCloud sent out the same message 20 times to all recipients.  We were able to transfer all calendar items and contacts back to his pc and then disable iCloud.  However, it still sent out the messages.  Any ideas?

    It's a carrier issue. I have AT&T and had this issue with my friend (who had an Android) and my mother (who had a feature phone). Both of them have Verizon for service and I'm thinking the issue was on Verizon's end. They both just dealt with it as we tried all sorts of things to get this sorted out (other than contacting Verizon directly) and had no luck.
    They've both switched to iPhones so it's a moot point for us now, at least.
    ~Lyssa

  • It's currently taking me ages to send multiple emails as I'm having to copy and paste the email each time. Does anyone know if there is a way that I can send the same email several times but that can be addressed (Dear....) to different people?

    It's currently taking me ages to send multiple emails as I'm having to copy and paste the email each time. Does anyone know if there is a way that I can send the same email several times but that can be addressed (Dear....) to different people?

    Oh at least just duplicate the same email several times so all I will be maunally inserting each time will be the address/name??? Please help!!!

  • How to use rule and send the same email to multiple recipents

    Hi,
    My requirement is to send the workitem to the multiple recipents. one of my reiend suggest me to use the rule but i don't know how to use that .
    can any one of you suggest me how to use rule in workflow.
    Also i want to send the same email to multiple recipent .how can i do it by using the multiline variable...please advice me with example if possible..
    Note :- Is it necessary to saparate the email id with comma or i will add all the email next one another..
    Please suggest.
    Thanks in advance ,
    Anand

    Hi Anand,
    I would suggest you first follow the guidelines of the forum and a little searching. One of your questions has been asked just a few threads below.
    Regards,
    Martin

  • Need to know of a method / process that can be used to send the same msg to all those appearing in my email listings with the same extension after the "@" sign in their address(es) on my macbook [e.g., with "@gov.ca"; Snow Leopard].

    Need to know of a method / process that can be used to send the same msg to all those appearing in my email listings with the same extension after the "@" sign in their address(es) on my macbook [Snow Leopard].

    If you simply want to send the exact same message to everyone in your address book with emails ending in "@whatever.com", you can do the following:
    Create an email with subject, message and attachments but no addresses
    Open Address Book, All Contacts
    Search in Address Book for @whatever.com
    Select the results and drag them into the To: or Bcc: field of the email. If Bcc: then put your email address in the To: field.
    Send the email
    This will not personalize the emails (such as with "Dear firstname:" at the top of the message) but it will let you send an idential message to everyone who meets your criteria.

  • Can we send the same message two different recievers with sequence

    Hi,
    i am sending the same message to two different receviers without using BPM.
    now i require to send with sequence.is it possible without BPM?

    Hey
    There are two options for this
    First one is to use Wait step in BPM as other experts suggested.
    Second one is a dirty way around,what you can do is send the second message to a dummy receiver first(may be a file on your XI server),then design one bypass scenario which will pick up the file after a specified time interval(give the poling interval you want).
    i would go for BPM coz its pretty straight forward,but in case you want to avoid BPM then u can use the second approach
    for bypass scenario,have a look at the following
    How to send any data (even binary) through XI, without using the Integration Repository

  • Send the same   message to two receivers with some  time difference..

    Hi
      I want to send the same message to Two receivers  with the slight time difference.. becuase  but not at the same time.. if the same time means.. just we can  specify the two receivers in the one receiver determination..
       but  if i want to send the   same message to Two  reveivers with the time difference means..(after sending the  message to first receiver.. after  some time gap.. i need to send the  message to second receiver..
      this type of scenarios how can we do.. is it possible to do with out BPM...  please suggest me the solution..
    Thanks
    Jain .P

    Hi Jain,
    With BPM you can easily do it.
    i am giving you the steps:
    1)first add a receive strep to get your message
    2)then, put a receiver determination step with a multiline receiver container element assigned to its Receivers property.
    3)then, put a block in dynamic mode(ie. ForEach/ParForEach mode) and assign the multiline receiver container element to its multiline element and assign a simple(single line) receiver container element to its current line property.
    4) add a send step within the block, choose Receivers List in its Receiver From property and choose the current line receiver element in its Receivers property.
    5) then add a wait step in the BPM, in its type select Wait Specified Time Period and then mention the duration in your desired time unit.
    **Reward points if helpful...
    --Sankar Choudhury

  • How to send the same message to two SMTP servers

    hi,
    I need to send a message to two different SMTP servers.
    I want to avoid the creation of new MimeMessage with a new Session.
    the only way I've found was to keep a reference to the Properties instance that was used in the Session creation, and modify its "mail.smtp.host" property.
    Is there another way? I must be missing something.
    thanks,
    ofer

    hi,
    I've already found the solution, so I'll post it here.
    first I'll explain the purpose:
    I needed to send the same message to a normal email server, and (for some of the recipients) to a special SMTP server that is on a different machine.
    the following code demonstrate the solution.
    thanks for your help.
    ofer
    ----------code---------------
    public class MultipleSendTest {
    private final static Session server1 = createSession("somesmtp_server.com");
    private final static Session _server2 = createSession("another_smtp_server.com");
    public static void main(String args[]) throws Exception {
    //create the message
    MimeMessage m = new MimeMessage(_server1);
    m.setText("body text");
    m.addRecipients(Message.RecipientType.TO, "[email protected]");
    m.setFrom(new InternetAddress("[email protected]"));
    //send
    send(m, _server1);
    send(m, _server2);
    private static void send(MimeMessage message, Session session) {
    //for logging only
    String host = session.getProperty("mail.smtp.host");
    try {
    Transport transport = session.getTransport("smtp");
    transport.connect();
    transport.sendMessage(message, message.getAllRecipients());
    System.out.println("sent to " + host);
    transport.close();
    } catch (MessagingException e) {
    System.out.println("failed to send to " + host);
    private static Session createSession(String host) {
    Properties properties = new Properties();
    properties.setProperty("mail.smtp.host", host);
    return Session.getInstance(properties);
    ----------code---------------

  • How do I send the same email to multiple addresses from my address book?

    I need to send the same email to many people on a regular basis. I especially entered all my contacts in the address book. Now I find out that I can only click on one of my contacts email address to create a new message. But I need to send 1 email to about 50 people. How do I go about this?

    Firefox has no email features, if you are using a webmail service in Firefox you need to ask the support for the webmail service. Any email features will be part of the webmail service.
    If your question is about Thunderbird, you can ask in one of these forums:
    * http://forums.mozillazine.org/viewforum.php?f=39
    * http://getsatisfaction.com/mozilla_messaging

  • Model edit failed, the same property cannot appear twice

    I imported a flex 3 project into flash builder but in the design view I'm getting
    model edit failed, the same property cannot appear twice
    I'm not sure how to correct this.

    If this helps I have a copy of the same project in FB 3 (never been imported into FB4) and I can't debug the project. When I try and click on the dropdown arrow next to the debug icon nothing happens, no list of options appears (open debug dialogue etc).
    The same problems occors in the FB 4 version

  • Why some emails sent with OS X Mail is not delivered, and if I send the same e mail from the website of my hosting provider, to the same recipients, they are delivered?

    Sometime, when I send an email with my Mac Book Pro, i receive the message:
    Hi. This is the qmail-send program at smtplqs01.aruba.it.
    I'm afraid I wasn't able to deliver your message to the following addresses.
    This is a permanent error; I've given up. Sorry it didn't work out.
    But if I try to send the same messagge, at the same email address, from the web site of my hosting providere, ther are not problem...
    Someone can help me?
    Thanks!!!

    Could be a number of things, among them the fact that the recipient's inbox is full, or his/her ISP email server is a bit slow at hand-shaking with yours, and this of course can vary depending on the fact that the recipient's account is IMAP or POP.
    When you send an email from a webmail, the grunt work is done by the SMTP server, and it's up to it to manage the multiple requests, their number, their frequency, their routing, etc... When you send an email from your Mail app, it'll send it once to your SMTP server, who'll process it a certain number of times before giving up, but you'll receive only one failure message.
    If the recipient's an Microsoft Exchange account, you must know that those servers sometimes send and receive email in bulk, and at a variable refresh rate, hence the "Sorry, your email couldn't be distributed...".

  • HT1391 After deleting a purchased video that, then re-downloading I now have the same exact video showing twice in iTunes & iPhone.  How do I get one to go away?

    After deleting a purchased video that, then re-downloading I now have the same exact video showing twice in iTunes & iPhone.  How do I get one to go away?

    Verify/repair your disk first (not just permissions), as described here:
    The Repair functions of Disk Utility: what's it all about?
    After having fixed all filesystem issues, if any, and making sure that there's enough space available on the startup disk (a few GB, plus the space needed to make a backup copy of the Mail folder), try this:
    1. Quit Mail if it's running.
    2. In the Finder, go to ~/Library/Mail/. Make a backup copy of this folder, just in case something goes wrong -- e.g. by dragging it to the Desktop while holding the Option (Alt) key down.
    3. Locate Envelope Index and move it to the Trash. If you see an Envelope Index-journal file there, delete it as well.
    4. Open Mail. It will tell you that your mail needs to be "imported". Click Continue and Mail will proceed to re-create Envelope Index -- Mail says it's "importing", but it just re-creates the index if the mailboxes are already in Mail 2.x format.
    BTW, you haven't answered which mailbox has the problem. I could be that just rebuilding that mailbox fixes it -- you should verify/repair the disk and make a backup copy of the Mail folder first, nevertheless, though.
    Note: For those not familiarized with the ~/ notation, it refers to the user's home folder, i.e. ~/Library is the Library folder within the user's home folder.

  • How to avoid purchasing multiple things that are the same but different titles

    How can I avoid purchasing multiple things that are the same but have multiple names but is the same purchase for the same use?

    "Things"?  What things?  Apps for keeping track of when to change cat litter?  30 different versions of "twinkle, twinkle little star" played by everything from punk rockers to Gregorian chant?  Videos on the best way to make Christmas cake?

  • TS3798 Have 2 ipads setup the same but 1 no longer connects to the network. Have reset network settings and tried to reconnect but no luck. Any advice?

    Have 2 ipads setup the same but 1 no longer connects to the network. Have reset network settings and tried to reconnect but no luck. Any advice?

    Have you tried rebooting your wireless router by removing power from it for about 30 seconds, then powering it back up?

Maybe you are looking for

  • What is causing Motion 5 to crash overtime I attempt to export movie?

    Hi, I just purchased Motion 5 for my iMac and after creating my first project I've attempted now multiple times, to export it as a movie and EVERY time I do it crashes.  I've tried restarting the program, shutting down my computer, installing the lat

  • Canon 5d iii, Cant open my Raw images in bridge or photoshop

    I have installed the most recent updates (8.3) and I still can't open my Raw files in bridge or photoshop CS5. Can someone please help me?

  • Problems with processing outbound IDocs in background processes

    Hello everybody, I have a question for working with ABAP-PSS Ports. The behvaiour is that I want to send master data, for example customers, to a function module. This function module works like an converter which process and writes the files in the

  • Year End Transactions

    As per To Be in BBP, How transactions to be done in SAP? Automatically or Manually?

  • Internal link to external email

    Hi, I'm trying to test if the exchange 2013 can connect to outside through the EDGE. How can I link a internal user to a Hotmail account?? [email protected]  -->  [email protected] Also, is Outlook possible to create a shared account?? I mean differe