[jboss-user] [JBoss Cache: Core Edition] - FileCacheLoader failing with EOFException with fix

e2open do-not-reply at jboss.com
Tue Mar 18 00:05:39 EDT 2008


    File cache loader in a cluster was failing with EOF exception while restoring an object, under load. It looks like the original hash map was not getting written properly. The original code is given below:

   protected void storeAttributes(Fqn fqn, Map attrs) throws Exception
   {
      File f = getDirectory(fqn, true);
      File child = new File(f, DATA);
      if (!child.exists())
         if (!child.createNewFile())
            throw new IOException("Unable to create file: " + child);
      FileOutputStream out = new FileOutputStream(child);
      ObjectOutputStream output = new ObjectOutputStream(out);
      output.writeObject(attrs);
      out.close();
   }

    Changing the code as given below seems to fix the issue. 

   protected void storeAttributes(Fqn fqn, Map attrs) throws Exception
   {
      File f = getDirectory(fqn, true);
      File child = new File(f, DATA);
      if (!child.exists())
         if (!child.createNewFile())
            throw new IOException("Unable to create file: " + child);
      FileOutputStream out = new FileOutputStream(child);
      try
      {
        MarshalledValueOutputStream output =
            new MarshalledValueOutputStream(out);
        output.writeObject(attrs);
        output.close();
        out = null;
      }
      finally
      {
        if(out != null)
          out.close();
      }
   }



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4137259#4137259

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4137259



More information about the jboss-user mailing list