title: java.lang.StackOverflowError while converting BindingResult to JSON using Gson
body: <p>Environment:<br>
    Spring boot- 1.2.3<br>
  <strong>Issue</strong> :  </p>
  
  <p>When <code>BindingResult</code> is added as next argument to <code>@Valid</code> argument for controller method like below, keep on getting  <code>java.lang.StackOverflowError</code> </p>
  
  <pre><code>@RequestMapping(value = "/employees", method = RequestMethod.POST, consumes = "application/json")
  public void createEmployee(HttpServletRequest request, @Valid @RequestBody Employee employee, BindingResult result){
      logger.debug("Creating Employee [" + employee.getForename() + " " + employee.getSurname() + "]");
  }
  </code></pre>
  
  <p>If <code>BindingResult</code> method argument is removed, it works fine.<br>
  <strong><em>Update start</em></strong><br>
  Found the issue, <code>StackOverflowError</code> occurred while converting <code>BindingResult</code> instance to <code>JSON</code> using below code:   </p>
  
  <pre><code>//log all method arguments   
  com.google.gson.Gson gson = new com.google.gson.Gson();
  String json = gson.toJson(bindingResultArgFromControllerMethod);
  </code></pre>
  
  <p>Framework code uses <code>Gson</code> to convert method arguments to <code>JSON</code> for logging. </p>
  
  <p>Is there way to avoid/handle this exception?<br>
  <strong><em>Update end</em></strong>  </p>
  
  <p><strong>Relevant Stack trace :</strong>   </p>
  
  <pre><code>    Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.StackOverflowError] with root cause
  
  java.lang.StackOverflowError: null
  //Repeatattive block start 
  at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:383)
  at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:378)
  //Repeatattive block end 
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:155)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
  at com.google.gson.Gson.getAdapter(Gson.java:407)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.&lt;init&gt;(ReflectiveTypeAdapterFactory.java:106)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
  at com.google.gson.Gson.getAdapter(Gson.java:407)
  </code></pre>