Announcement Announcement Module
No announcement yet.
ResponseStatus not consistently working Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ResponseStatus not consistently working

    I'm seeing some issues with the ResponseStatus annotation. Using the below code (scala):

        @ResponseStatus(value = HttpStatus.BAD_REQUEST)
        def handleMethodArgumentNotValidException(error: MethodArgumentNotValidException):String = {
    	  val o = new JSONObject
    	  val errors = error.getBindingResult().getFieldErrors().groupBy(_.getField())
    	  errors.foreach{case (field, fieldErrors) => {
    	    val jsonErrors = new JSONArray
    	    fieldErrors.foreach(error => {
    	    o.put(field, jsonErrors)
    When seeing validation problems, this exception handler gets called. It returns the field errors as JSON in the response body and is supposed to return a BAD_REQUEST status. It always manages to return the correct body but seemingly at random will sometimes return a 200 status code. It seems to only happen in our test environment which runs JBoss-4.2.3.GA. On my local machine using Jetty(6.1.3) I haven't seen this issue. Because it happens seemingly at random it seems to me that some race condition may be involved. Anyone have ideas around this? I can try to provide more information if needed.