Search code examples
apache-flexarraysamfremoteobject

Flex RemoteObject: Arrays with same values reference same memory


If I send remote data from Zend_Amf to Flex, if two array properties on the object have the same data values they are deserialized at the remote end with the same memory storage.

Example: AS3 object:

Snippet:

[RemoteClass(alias="TestVO")]
public class TestVO
{
  public var test1:Array;
  public var test2:Array;
}

When this receives remote data from Zend_Amf server, if the array data are identical it allocates the same storage to the two arrays.

Eg: From remote (ZendAMF) object I send:

$this->test1 = array("foo", "bar");
$this->test2 = array("foo", "bar");

When I debug the TestVO object in Flex debugger I get:

test1 Array(@597d779)
test2 Array(@597d779)

ie: they reference the same array object.

If I send from the remote server slightly different values for the 2 arrays:

$this->test1 = array("foo", "bar");
$this->test2 = array("bar", "foo");

In the Flex debugger the TestVO object now has two seperate arrays as you'd expect:

test1 Array(@54cb7e9)
test2 Array(@54cb741)

AMF output looks Ok, it always sends two seperate values for test1/test2 even if they have the same values, so I'm guessing it's the way Flex de-serializes this?

Any ideas? Thanks.


Solution

  • Found bug ZF-7634 on Zend Framework implementation of AMF. It is serializing the arrays incorrectly.

    http://framework.zend.com/issues/browse/ZF-7634