incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r486875 - in /incubator/yoko/trunk: core/src/main/java/org/apache/yoko/orb/CORBA/ core/src/main/java/org/apache/yoko/orb/OB/ rmi-impl/src/main/java/org/apache/yoko/rmi/impl/
Date Wed, 13 Dec 2006 22:38:41 GMT
Author: rickmcguire
Date: Wed Dec 13 14:38:39 2006
New Revision: 486875

URL: http://svn.apache.org/viewvc?view=rev&rev=486875
Log:
YOKO-246 RMI type marshalling not handling multi-dimensional object arrays correctly.


Modified:
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java
    incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
    incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CopyState.java
    incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java
    incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java
    incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectReader.java

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java?view=diff&rev=486875&r1=486874&r2=486875
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java Wed
Dec 13 14:38:39 2006
@@ -65,7 +65,7 @@
         if (id.length() > 0) {
             tc = cache_.get(id);
             if (tc != null) {
-                _OB_skip(length + 8 + startPos - buf_.pos_);
+                _OB_skip(length + startPos - buf_.pos_);
             }
         }
 
@@ -128,13 +128,15 @@
 
             case org.omg.CORBA.TCKind._tk_objref: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     tc = (TypeCode) org.apache.yoko.orb.OB.TypeCodeFactory
                             .createInterfaceTC(id, read_string());
@@ -151,13 +153,15 @@
             case org.omg.CORBA.TCKind._tk_struct:
             case org.omg.CORBA.TCKind._tk_except: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
-                _OB_readEndian();
+                _OB_readEndian();  
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     //
                     // For potentially recursive types, we must
@@ -190,13 +194,15 @@
 
             case org.omg.CORBA.TCKind._tk_union: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     //
                     // For potentially recursive types, we must construct
@@ -278,13 +284,15 @@
 
             case org.omg.CORBA.TCKind._tk_enum: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     String name = read_string();
                     int num = read_ulong();
@@ -342,13 +350,15 @@
 
             case org.omg.CORBA.TCKind._tk_alias: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     tc = (TypeCode) org.apache.yoko.orb.OB.TypeCodeFactory
                             .createAliasTC(id, read_string(), readTypeCodeImpl(
@@ -366,13 +376,15 @@
 
             case org.omg.CORBA.TCKind._tk_value: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     //
                     // For potentially recursive types, we must
@@ -412,13 +424,15 @@
 
             case org.omg.CORBA.TCKind._tk_value_box: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     tc = (TypeCode) org.apache.yoko.orb.OB.TypeCodeFactory
                             .createValueBoxTC(id, read_string(),
@@ -435,13 +449,15 @@
 
             case org.omg.CORBA.TCKind._tk_abstract_interface: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     tc = (TypeCode) org.apache.yoko.orb.OB.TypeCodeFactory
                             .createAbstractInterfaceTC(id, read_string());
@@ -457,13 +473,15 @@
 
             case org.omg.CORBA.TCKind._tk_native: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     tc = (TypeCode) org.apache.yoko.orb.OB.TypeCodeFactory
                             .createNativeTC(id, read_string());
@@ -479,13 +497,15 @@
 
             case org.omg.CORBA_2_4.TCKind._tk_local_interface: {
                 int length = read_ulong(); // encapsulation length
+                // save this position after the read, since we might be on a chunk boundary.
+                int typePos = buf_.pos_;
                 boolean swap = swap_;
                 _OB_readEndian();
 
                 String id = read_string();
 
                 if (isTopLevel && cache_ != null)
-                    tc = checkCache(id, oldPos, length); // may advance pos
+                    tc = checkCache(id, typePos, length); // may advance pos
                 if (tc == null) {
                     tc = (TypeCode) org.apache.yoko.orb.OB.TypeCodeFactory
                             .createLocalInterfaceTC(id, read_string());

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java?view=diff&rev=486875&r1=486874&r2=486875
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java Wed
Dec 13 14:38:39 2006
@@ -1284,6 +1284,9 @@
 
         int reqId = upcall.requestId();
         try {
+            // print this exception out here so applications have at stack trace to work

+            // with for problem determination.
+            ex.printStackTrace();
             outgoing.writeReplyHeader(reqId,
                     org.omg.GIOP.ReplyStatusType_1_2.SYSTEM_EXCEPTION, scl);
             Util.marshalSystemException(out, ex);

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java?view=diff&rev=486875&r1=486874&r2=486875
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java Wed Dec
13 14:38:39 2006
@@ -836,32 +836,30 @@
 
         String className = Util.idToClassName (repid, "");
         String codebase  = h.codebase;
+        Class repoClass = null;
 
-        if (clz == null)
+        if (codebase == null) {
+            codebase = in_.__getCodeBase ();
+        }
+
+        try
         {
-            if (codebase == null) {
-                codebase = in_.__getCodeBase ();
-            }
+            repoClass = javax.rmi.CORBA.Util.loadClass
+                (className,
+                 codebase,
+                 Util.getContextClassLoader ());
+        }
+        catch (ClassNotFoundException ex)
+        {
+            if (codebase == null || codebase.length () == 0) {
+                // ignore, we'll try to grab the codebase, and then
+                // call loadClass again.
+            } else {
+                            // TODO: Add minor code
+                throw new org.omg.CORBA.MARSHAL
+                    ("class "+className
+                     +" not found (cannot load from "+codebase+")" );
 
-            try
-            {
-                clz = javax.rmi.CORBA.Util.loadClass
-                    (className,
-                     codebase,
-                     Util.getContextClassLoader ());
-            }
-            catch (ClassNotFoundException ex)
-            {
-                if (codebase == null || codebase.length () == 0) {
-                    // ignore, we'll try to grab the codebase, and then
-                    // call loadClass again.
-                } else {
-                		// TODO: Add minor code
-                    throw new org.omg.CORBA.MARSHAL
-                        ("class "+className
-                         +" not found (cannot load from "+codebase+")" );
-                    
-                }
             }
         }
         
@@ -870,8 +868,7 @@
             remoteCodeBase = in_.__getSendingContextRuntime ();
         }
 
-            if (clz == null) {
-
+            if (repoClass == null) {
                 if (codebase == null && remoteCodeBase != null)
                 {
                     try {
@@ -890,7 +887,7 @@
                 
                 try
                 {
-                    clz = javax.rmi.CORBA.Util.loadClass
+                    repoClass = javax.rmi.CORBA.Util.loadClass
                         (className,
                          codebase,
                          Util.getContextClassLoader ());
@@ -914,7 +911,11 @@
             	remoteCodeBase = ((CodeBaseProxy) remoteCodeBase).getCodeBase();
             }
 
-            return valueHandler.readValue (in_, h.headerPos, clz,
+            if (clz != null && repoClass != null && !clz.isAssignableFrom(repoClass))
{
+                throw new org.omg.CORBA.MARSHAL("Incompatible type " + className);
+            }
+
+            return valueHandler.readValue (in_, h.headerPos, repoClass,
                     repid, remoteCodeBase);
 
     }
@@ -1255,6 +1256,7 @@
 
         org.omg.CORBA.TypeCode origTC = org.apache.yoko.orb.CORBA.TypeCode
                 ._OB_getOrigType(tc);
+
 
         //
         // Check if the Any contains an abstract interface

Modified: incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java?view=diff&rev=486875&r1=486874&r2=486875
==============================================================================
--- incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
(original)
+++ incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
Wed Dec 13 14:38:39 2006
@@ -18,8 +18,11 @@
 package org.apache.yoko.rmi.impl;
 
 import java.lang.reflect.Array;
+import java.util.Vector;
 import java.util.logging.Logger;
 
+import javax.rmi.CORBA.Util;
+
 import org.omg.CORBA.MARSHAL;
 import org.omg.CORBA.ORB;
 import org.omg.CORBA.TypeCode;
@@ -218,10 +221,9 @@
 
         logger.finer("writing " + getJavaClass().getName() + " size="
                 + arr.length);
-        org.omg.CORBA_2_3.portable.OutputStream _out = (org.omg.CORBA_2_3.portable.OutputStream)
out;
 
         for (int i = 0; i < arr.length; i++) {
-            _out.write_value((java.io.Serializable)arr[i]);
+            javax.rmi.CORBA.Util.writeAny(out, arr[i]); 
         }
     }
 
@@ -247,7 +249,6 @@
                     // reader.addValueBox (ex.offset, new ArrayBox (i, arr));
                 }
             }
-
             return (java.io.Serializable) arr;
 
         } catch (java.io.IOException ex) {
@@ -404,12 +405,7 @@
             // len="+length+"; type="+elementType);
 
             for (int i = 0; i < length; i++) {
-                try {
-                    arr[i] = reader.readValueObject();
-                } catch (org.omg.CORBA.portable.IndirectionException ex) {
-                    arr[i] = offsetMap.get(new Integer(ex.offset));
-                    // reader.addValueBox (ex.offset, new ArrayBox (i, arr));
-                }
+                arr[i] = reader.readValueObject(elementType);
             }
 
             return (java.io.Serializable) arr;

Modified: incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CopyState.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CopyState.java?view=diff&rev=486875&r1=486874&r2=486875
==============================================================================
--- incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CopyState.java (original)
+++ incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CopyState.java Wed
Dec 13 14:38:39 2006
@@ -328,6 +328,10 @@
         public Object readValueObject() {
             return dequeue();
         }
+
+        public Object readValueObject(Class clz) {
+            return dequeue();
+        }
         
         public org.omg.CORBA.Object readCorbaObject(Class type) {
             return (org.omg.CORBA.Object) dequeue();

Modified: incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java?view=diff&rev=486875&r1=486874&r2=486875
==============================================================================
--- incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java
(original)
+++ incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java
Wed Dec 13 14:38:39 2006
@@ -157,6 +157,15 @@
             return offsetMap.get(new Integer(ex.offset));
         }
     }
+
+    public Object readValueObject(Class clz)
+            throws org.omg.CORBA.portable.IndirectionException {
+        try {
+            return in.read_value(clz);
+        } catch (org.omg.CORBA.portable.IndirectionException ex) {
+            return offsetMap.get(new Integer(ex.offset));
+        }
+    }
     
     public org.omg.CORBA.Object readCorbaObject(Class type) {
 	org.omg.CORBA.Object objref = in.read_Object();

Modified: incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java?view=diff&rev=486875&r1=486874&r2=486875
==============================================================================
--- incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java
(original)
+++ incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java
Wed Dec 13 14:38:39 2006
@@ -387,7 +387,7 @@
     public void read(ObjectReader reader, Object obj)
             throws java.io.IOException {
         try {
-            field.set(obj, reader.readValueObject());
+            field.set(obj, reader.readValueObject(getType()));
         } catch (IllegalAccessException ex) {
             throw new org.omg.CORBA.MARSHAL(ex.getMessage());
         }

Modified: incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectReader.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectReader.java?view=diff&rev=486875&r1=486874&r2=486875
==============================================================================
--- incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectReader.java
(original)
+++ incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectReader.java
Wed Dec 13 14:38:39 2006
@@ -133,6 +133,9 @@
     public abstract Object readValueObject()
             throws org.omg.CORBA.portable.IndirectionException;
 
+    public abstract Object readValueObject(Class clz)
+            throws org.omg.CORBA.portable.IndirectionException;
+
     public abstract org.omg.CORBA.Object readCorbaObject(Class type);
     
     public abstract java.rmi.Remote readRemoteObject(Class type);



Mime
View raw message