Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3636436
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:01:59+00:00 2026-05-19T01:01:59+00:00

I have a server on which I keep track of some data. When I

  • 0

I have a server on which I keep track of some data. When I connect to the server with the administrator application to check out the current state of the data. I use a refresh rate of 5 seconds. The first time the server sends the data, it works. But the second time, when the data changed, the admin-side does not receive the up-to-date data. I’m sending the data, wrapped in a class, through an ObjectOutputStream and ObjectInputStream:

This is the wrapper class for the data:

public class Leerling implements Serializable {

    public int llnID;

    public String naam;
    public String voornaam;
    public String klas;
    public int klasNummer;
    public Date geboorteDatum;

    public String getFullName()
    {
        return voornaam + " " + naam;
    }

    @Override
    public String toString() {
        return "Leerling{" + "llnID=" + llnID + ", naam=" + naam + ", voornaam=" + voornaam + ", klas=" + klas + ", klasNummer=" + klasNummer + ", geboorteDatum=" + geboorteDatum + '}';
    }

}


public class SLeerling extends Leerling implements Serializable{

    public boolean voted;
    public int vote = -2;
}

What I tried is before reading the Object from the stream to call System.gc(); to make sure the object old object is not longer in memory. But without success.

Does someone know what the exact problem is? And how to make it possible to get the real up-to-date data?

Thanks in advance.


A second example of the problem:

I have again a wrapper class for some other data (It is an inner class):

public static class MonitorResponse implements Serializable
{
    public int numberOfLLN;
    public int blocked;
    public int blancos;
    public List<Integer> votes;
}

When I send the data the first time, it works. But the second time I send it (to update it), everything EXCEPT the List<Integer> votes is updated. So votes isn’t refreshed.
Then I solved it a bit tricky by replacing the List by an array:

public static class MonitorResponse implements Serializable
{
    public int numberOfLLN;
    public int blocked;
    public int blancos;
    public Integer[] votes;
}

And this works perfect. Strange if you ask me. The the other part of the code I changed almost nothing… (except to implement the array instead of the List)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:01:59+00:00Added an answer on May 19, 2026 at 1:01 am

    It’s probably the ObjectOutputStream causing the trouble.

    If you use a single ObjectOutputStream object on the server then you need to make sure you call reset on it, otherwise it will write shared references to previously-written objects. This sounds like what you are seeing.

    To illustrate the problem:

    class BrokenServer {
        void sendBrokenVoteData(ObjectOutputStream out) {
            out.writeObject(votes);
            changeVoteData(votes);
            out.writeObject(votes); // Writes a shared reference to "votes" WITHOUT updating any data.
        }
    }
    
    class FixedServer {
        void sendFixedVoteData(ObjectOutputStream out) {
            out.writeObject(votes);
            changeVoteData(votes);
            out.reset(); // Clears all shared references.
            out.writeObject(votes); // Writes a new copy of "votes" with the new data.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server application which I want to protect from being stopped by
I have a java server which is using TCP and sockets to connect to
I have a FTP server which I use for Linux repository for RPM packages.
I have a web service which allows the users to upload and keep track
I have a n-tier C# ASP .Net application server which uses stored procedures to
I'm developing a C++ application which will run on a headless server and keep
I have a client/server application and I'm looking for some advice about how to
I have a server which already host ASP.Net website. I am migrating from blogger
I have a server which executes Python scripts from a certain directory path. Incidently
Hi I have a server which has several virtual hosts set up on it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.