0 Replies Latest reply on Jan 30, 2006 1:01 AM by Tim Fox

    NPE in JBossObjectOutputStream

    Tim Fox Master

      The following code gives a NPE when trying to write an int:

      FileOutputStream fos = new FileOutputStream("whatever");
      JBossObjectOutputStream os = new JBossObjectOutputStream(fos);
      os.writeInt(123);
      


      This happens if an attempt is made to write any primitive value before writeObject() has been called.

      Looking in the source, it seems the underlying DataOutputStream is not created in the constructor but in the writeObjectOverride method.

      AFAIK in the usage contract for an ObjectOuputStream there's no restriction that primitive values should be written only after writeObject has been called once.