Juan José Ramos Cassella created GEODE-6848:
-----------------------------------------------

             Summary: PreventReserializationSerializer: not enough information 
to deserialize repeated objects
                 Key: GEODE-6848
                 URL: https://issues.apache.org/jira/browse/GEODE-6848
             Project: Geode
          Issue Type: Improvement
          Components: querying
            Reporter: Juan José Ramos Cassella


In order to prevent re-serialization of already serialized objects, circular 
dependencies and infinite recursion, the {{PreventReserializationSerializer}} 
class maintains an internal {{Map}} of objects already seen and, instead of 
serializing the object again, it just adds some metadata ({{duplicate}} / 
{{@reference}}) to the output. The problem is that this metadata can't be used 
at all to instantiate the object by the user of the class, basically because 
the objects don't have an {{id}} or something that could be referenced from 
within the metadata.
The following is an example of the issue, the client of the class wouldn't know 
if the last element is a duplicate of the first or second {{Order}} within the 
array:

{code:java}
  private static class Order {
    private final String id;

    public Order(String id) {
      this.id = id;
    }
  }

  @Test
  public void whichOrder() {
    Order order1 = new Order("order1");
    Order order2 = new Order("order2");
    QueryResultFormatter queryResultFormatter = new 
QueryResultFormatter(100).add(RESULT, Arrays.asList(order1, order2, order1));

    System.out.println(queryResultFormatter.toString());
  }
{code}


{noformat}
{
  "result": [
    [
      "java.util.ArrayList",
      {
        "0": [
          "org.apache.geode.Order",
          {
            "id": [
              "java.lang.String",
              "order1"
            ]
          }
        ],
        "1": [
          "org.apache.geode.Order",
          {
            "id": [
              "java.lang.String",
              "order2"
            ]
          }
        ],
        "2": "duplicate org.apache.geode.Order"
      }
    ]
  ]
}
{noformat}





--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to