title: Jersey / JAXB: Unmarshaling of empty json array results in a list with one item where all fields are set to null
body: <p>I have a really simple rest web service returning a list of questions. This code works as expected when the number of questions returned are greater than zero. But if the server returns an empty json array like [], JAXB creates a list with one question instance where all fields are set to null! </p>
  
  <p>I'm new to both Jersey and JAXB so I don't know whether I haven't configured it correctly or whether this is a known problem. Any tips?</p>
  
  <p>Client configuration:</p>
  
  <pre><code> DefaultApacheHttpClientConfig config = new DefaultApacheHttpClientConfig();
   config.getProperties().put(DefaultApacheHttpClientConfig.PROPERTY_HANDLE_COOKIES, true);
   config.getClasses().add(JAXBContextResolver.class);
   //config.getClasses().add(JacksonJsonProvider.class); // &lt;- Jackson causes other problems
  
   client = ApacheHttpClient.create(config);
  </code></pre>
  
  <p>JAXBContextResolver:</p>
  
  <pre><code>@Provider
   public final class JAXBContextResolver implements ContextResolver&lt;JAXBContext&gt; {
  
    private final JAXBContext context;
    private final Set&lt;Class&gt; types;
    private final Class[] cTypes = { Question.class };
  
    public JAXBContextResolver() throws Exception {
     this.types = new HashSet(Arrays.asList(cTypes));
     this.context = new JSONJAXBContext(JSONConfiguration.natural().build(), cTypes);
    }
  
    @Override
    public JAXBContext getContext(Class&lt;?&gt; objectType) {
     return (types.contains(objectType)) ? context : null;
    }
  
   }
  </code></pre>
  
  <p>Client code:</p>
  
  <pre><code>public List&lt;Question&gt; getQuestionsByGroupId(int id) {
      return digiRest.path("/questions/byGroupId/" + id).get(new GenericType&lt;List&lt;Question&gt;&gt;() {});
  }
  </code></pre>
  
  <p>The Question class is just a simple pojo. </p>