title: Why is Jersey client inserting an object into my List when it should be empty?
body: <p>I've written a client for a REST service using Jersey. For some reason, when the JSON to be unmarshalled has an empty array, the List object has a single element in it. That object has all members set to null as if it was just constructed with the default constructor.</p>
  
  <p>Order.java:</p>
  
  <pre><code>@XmlRootElement
  public class Order {
  
      private int id;
      private List&lt;Photo&gt; photos;
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public List&lt;Photo&gt; getPhotos() {
          return photos;
      }
  }
  </code></pre>
  
  <p>Client code that consumes the JSON service:</p>
  
  <pre><code>Client client = Client.create();
  WebResource webResource = client.resource(environment.url);
  
  Order order = webResource.path("Orders")
          .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
          .accept(MediaType.APPLICATION_JSON_TYPE)
          .post(Order.class, formData);
  </code></pre>
  
  <p>The logs show that the JSON returned was:</p>
  
  <pre><code>{"id":704,"photos":[]}
  </code></pre>
  
  <p>However, the List "photos" is not empty as expected, but contains a single Photo object. All members of this object are null as if it was constructed with a default constructor.</p>
  
  <p>What is creating this object and why?</p>
  
  <hr>
  
  <p><strong>More details</strong>: A similar problem exists if instead of a List of objects, I attempt to deserialize a List of enums. In this case I also get a List of size 1 this time just containing "null".</p>