[Red5commits] [red5 commit] r3233 - java/server/branches/aclarke_autotest/src/org/red5/io/amf

codesite-noreply at google.com codesite-noreply at google.com
Tue Oct 14 12:03:51 PDT 2008


Author: art.clarke
Date: Tue Oct 14 12:03:37 2008
New Revision: 3233

Modified:
    java/server/branches/aclarke_autotest/src/org/red5/io/amf/Input.java

Log:
- Fix LONG lived bug in AMF0 reference handling.

   Joachim introduced the concept of RTMP Reference Mode to work around
   this which adjusted the reference ID by -1 if in RTMP mode.  This never
   really worked.

   The root of the issue was the AMF0 Map decoding would not store it's own
   reference ID until it had deserialized all members.  That meant that any
   member with a reference would be off by one in their ref ids.

   The fix was to remove the concept of RTMP versus Remoteing mode, but
   to correctly store the Map reference before deserializing any members.

   Checking in to see if smoke tests pass as well.



Modified:  
java/server/branches/aclarke_autotest/src/org/red5/io/amf/Input.java
==============================================================================
--- java/server/branches/aclarke_autotest/src/org/red5/io/amf/Input.java	 
(original)
+++ java/server/branches/aclarke_autotest/src/org/red5/io/amf/Input.java	 
Tue Oct 14 12:03:37 2008
@@ -342,6 +342,9 @@
  		log.debug("Read start mixed array: {}", maxNumber);
  		Object result;
  		final Map<Object, Object> mixedResult = new LinkedHashMap<Object,  
Object>(maxNumber);
+		// we must store the reference before we deserialize any items in it to  
ensure
+		// that reference IDs are correct
+		int reference = storeReference(mixedResult);
  		while (hasMoreProperties()) {
  			String key = getString(buf);
  			log.debug("key: {}", key);
@@ -368,7 +371,8 @@
  			}
  			result = mixedResult;
  		}
-		storeReference(result);
+		// Replace the original reference with the final result
+		storeReference(reference, result);
  		skipEndObject();
  		return result;
  	}
@@ -577,11 +581,7 @@
  	 * @return Object       Read reference to object
  	 */
  	public Object readReference(Type target) {
-		if (referenceMode == ReferenceMode.MODE_RTMP) {
-			return getReference(buf.getUnsignedShort() - 1);
-		} else {
-			return getReference(buf.getUnsignedShort());
-		}
+		return getReference(buf.getUnsignedShort());
  	}

  	/**



More information about the Red5commits mailing list