title: Java: Serialization doesn't work for the second time
body: <p>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:</p>
  
  <p>This is the wrapper class for the data:</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>What I tried is before reading the Object from the stream to call <code>System.gc();</code> to make sure the object old object is not longer in memory. But without success.</p>
  
  <p>Does someone know what the exact problem is? And how to make it possible to get the real up-to-date data?</p>
  
  <p>Thanks in advance.</p>
  
  <hr>
  
  <p>A second example of the problem:</p>
  
  <p>I have again a wrapper class for some other data (It is an inner class):</p>
  
  <pre><code>public static class MonitorResponse implements Serializable
  {
      public int numberOfLLN;
      public int blocked;
      public int blancos;
      public List&lt;Integer&gt; votes;
  }
  </code></pre>
  
  <p>When I send the data the first time, it works. But the second time I send it (to update it), everything EXCEPT the <code>List&lt;Integer&gt; votes</code> is updated. So <code>votes</code> isn't refreshed.
  Then I solved it a bit tricky by replacing the List by an array:</p>
  
  <pre><code>public static class MonitorResponse implements Serializable
  {
      public int numberOfLLN;
      public int blocked;
      public int blancos;
      public Integer[] votes;
  }
  </code></pre>
  
  <p>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)</p>