src/java.corba/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -30,10 +30,11 @@
  */
 
 package com.sun.corba.se.impl.io;
 
 import java.io.IOException;
+import java.io.NotActiveException;
 import java.io.OutputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectOutput;
 import java.util.Map;
 import java.util.HashMap;

@@ -152,11 +153,13 @@
 
     public abstract void defaultWriteObjectDelegate();
 
     public ObjectOutputStream.PutField putFields()
         throws IOException {
+        if (putFields == null) {
         putFields = new HookPutFields();
+        }
         return putFields;
     }
 
     // Stream format version, saved/restored during recursive calls
     protected byte streamFormatVersion = 1;

@@ -173,13 +176,16 @@
     // See java.io.ObjectOutputStream.PutFields
     public void writeFields()
         throws IOException {
 
         writeObjectState.defaultWriteObject(this);
-
+        if (putFields != null) {
         putFields.write(this);
+        } else {
+            throw new NotActiveException("no current PutField object");
     }
+    }
 
     abstract org.omg.CORBA_2_3.portable.OutputStream getOrbStream();
 
     protected abstract void beginOptionalCustomData();