You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by ri...@apache.org on 2007/01/18 12:00:23 UTC

svn commit: r497413 - /incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java

Author: rickmcguire
Date: Thu Jan 18 04:00:19 2007
New Revision: 497413

URL: http://svn.apache.org/viewvc?view=rev&rev=497413
Log:
YOKO-277 Errors in handling indirections when writeReplace() is involved.


Modified:
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java?view=diff&rev=497413&r1=497412&r2=497413
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java Thu Jan 18 04:00:19 2007
@@ -417,6 +417,8 @@
         //
         java.io.Serializable repValue
             = valueHandler.writeReplace (value);
+        
+        java.io.Serializable originalValue = null; 
 
         //
         // Repeat base checks if value was replaced
@@ -433,11 +435,19 @@
             }
 
             if (repValue instanceof java.lang.String) {
-	    			org.omg.CORBA.WStringValueHelper.write (out_, (String)value);
-	    			return;
+    			int pos = out_._OB_pos();
+       			org.omg.CORBA.WStringValueHelper.write (out_, (String)repValue);
+                instanceTable_.put (repValue, new Integer (pos));
+                // we record the original value position so that another attempt to write out 
+                // the original object will resolve to the same object. 
+                instanceTable_.put (value, new Integer (pos));
+       			return;
             }
-
+            // save the original value because we want to record that object in the 
+            // indirection table also, once we've established the offset position. 
+            originalValue = value; 
             value = repValue;
+            
         }
 
         //
@@ -468,6 +478,11 @@
 
         int pos = beginValue (tag, ids, codebase, isChunked);
         instanceTable_.put (value, new Integer (pos));
+        // if this was replace via writeReplace, record the original 
+        // value in the indirection table too. 
+        if (originalValue != null) {
+            instanceTable_.put (originalValue, new Integer (pos));
+        }
         valueHandler.writeValue (out_, value);
         endValue ();
 	}