title: Spring4 @RequestBody required doesn't work
body: <p>I've upgrade Spring version from 4.0.x to 4.2.3 (4.2.4 just now), suddenly, "required = false" property from @RequestBody annotation does not work as expected (as it did before the version change).</p>
  
  <p>Server response with HttpStatus 415 - Unsupported Media Type.</p>
  
  <p>The controller method (same for every Spring versions).</p>
  
  <pre><code>@RequestMapping(value = "/entity/{entityId}/{from}/{size}", method = RequestMethod.POST)
  @ResponseBody
  @JsonView(ToShowIn.App.class)
  public ResponseEntity&lt;?&gt; getActiveEntityPaged(
      @PathVariable int entityId, @PathVariable int from, @PathVariable int size, 
      @RequestBody(required = false) EntityFilterParam entityFilterParam) {
  
      ...
  }
  </code></pre>
  
  <p>Really, it's not problem because from the client, avoiding send null, for example, setting empty <code>EntityFilterParam</code> instance is enough to fix it. But I would like to understand if this bothering issue is because a wrong concept from me or rather is due for a bug from the new Spring versions.</p>
  
  <p>UPDATE#1</p>
  
  <p>Versions</p>
  
  <pre><code>&lt;spring-version&gt;4.2.4.RELEASE&lt;/spring-version&gt;
  &lt;jackson-2-version&gt;2.3.2&lt;/jackson-2-version&gt;
  </code></pre>
  
  <p>Request is from Android device, working with spring-android library (AKA RestTemplate).</p>
  
  <p>Generic method, works on 4.0.x version, where EntityFilterParam can be null.</p>
  
  <pre><code>super.doRestList(
      new HttpEntity&lt;EntityFilterParam&gt;(EntityFilterParam, this.getHttpHeaders()),
      HttpMethod.POST,
      urlBuilder);
  </code></pre>
  
  <p>On 4.2.3 and 4.2.4, to fix the issue, EntityFilterParam can't be null. -> HttpStatus 415 - Unsupported Media Type. To fix it.</p>
  
  <pre><code>super.doRestList(
      new HttpEntity&lt;EntityFilterParam&gt;((EntityFilterParam != null) ? EntityFilterParam : new EntityFilterParam(), this.getHttpHeaders()),
      HttpMethod.POST,
      urlBuilder);
  </code></pre>
  
  <p>Inside doRestList, RestTemplate request is performed.</p>
  
  <pre><code>final ResponseEntity&lt;E[]&gt; responseEntity =
      (ResponseEntity) super.getRestTemplate()
          .exchange(urlBuilder.getURL(), httpMhetod,
              requestEntity, this.entityArray.getClass());
  </code></pre>
  
  <p>Where, <code>urlBuilder.getURL()</code> (URL string, here @PathVariables are working fine) and <code>this.getHttpHeaders()</code> return the next HttpHeaders configuration.</p>
  
  <pre><code>RestFactory.httpHeaders = new HttpHeaders();
  
  RestFactory.httpHeaders.setAuthorization(this.getAuthorization(user));
  RestFactory.httpHeaders.set(HttpHeaders.CONNECTION, "Close"); // Switch off keep-alive.
  RestFactory.httpHeaders.set(HttpHeaders.ACCEPT_LANGUAGE, "en-US,en;q=0.8");
  RestFactory.httpHeaders.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
  </code></pre>
  
  <p><code>super.getRestTemplate()</code> is the singleton method which returns the RestTemplate instance set with my own CloseableHttpClient configuration.</p>
  
  <p>I know <code>HttpHeaders.CONTENT_TYPE</code> for <code>application/json</code> is missing, but is consciously, in fact, it works when the http body payload is not empty, and fails when it is.</p>
  
  <p>When the error occurs, 415 is performed before the flow of the request goes inside the controller method, therefore, any operation is doesn't performed.</p>
  
  <p>UPDATE#2</p>
  
  <p>Another interesting point, Jackson2 serializes the null value as "null" string, then the body payload is not being null, is filled with "null".</p>