Spring-framework: ExceptionHandlerExceptionResolver.setResponseBodyAdvice() Javadoc is incorrect

Created on 18 Nov 2019  路  8Comments  路  Source: spring-projects/spring-framework

The Javadoc for ExceptionHandlerExceptionResolver.setResponseBodyAdvice() states that it will "Add one or more components..."; however, it actually first clears the current list and effectively _sets_ the advice to the specified list.

This is in contrast to RequestMappingHandlerAdapter.setResponseBodyAdvice() which actually does _add_ the advice instead of clearing the current list.

Granted the name of the latter is misleading and should actually be addResponseBodyAdvice(), we likely will not want to change the semantics.

Thus, we should consider one of the following.

  1. Update Javadoc for ExceptionHandlerExceptionResolver.setResponseBodyAdvice() to reflect that it actually "sets" the list instead of adding.
  2. Stop invoking this.responseBodyAdvice.clear() so that ExceptionHandlerExceptionResolver.setResponseBodyAdvice() does what the Javadoc says it does.

Option # 2 would align the behavior in ExceptionHandlerExceptionResolver and RequestMappingHandlerAdapter.

web superseded documentation enhancement

All 8 comments

Team Decision: go with option # 2 but not until Spring Framework 5.3.

  1. Stop invoking this.responseBodyAdvice.clear() so that ExceptionHandlerExceptionResolver.setResponseBodyAdvice() does what the Javadoc says it does.

Ok mr

@ahmad222223, I've deleted your non-English comments. If you did not leave those in error, and actually meant to comment, perhaps try Google translate or similar.

Hey I'd like to start contributing to spring. I could take up the documentation change. If this isn't possible then could someone more experienced guide me on a smaller issue to get started with?

@sbrannen, @rstoyanchev : Would appreciate your inputs

Thanks

This issue is small enough if you'd like to give that a try. We also use the status: ideal-for-contribution label for issues that are straight-forward enough.

Great! I'll take this up then.

@rstoyanchev I've created a PR. Could you get it approved?

Superseded by #24204.

Was this page helpful?
0 / 5 - 0 ratings