Skip to content

Commit

Permalink
Address HttpStatus Incompatibility (PAYINP-2233) (#193)
Browse files Browse the repository at this point in the history
When building the forbidden response in the task management controller, when the caller does not have permission to do the operation, use the `ResponseEntity.status()` overload that takes an integer rather than the overload that takes a HttpStatus enum instance.

This addresses an issue whereby when the library is used with Spring 6, which changes the `status` method to take a `HttpStatusCode` interface implementation instead, a `NoSuchMethod` exception is raised. This appears due to the Spring 6 release breaking binary compatibility between Spring 5.

This change should allow the library to continue working in both Spring 5 and Spring 6, without the need for a separate Spring 6 compatible version of the library.
  • Loading branch information
mscott-tw authored Dec 19, 2023
1 parent 91d0660 commit a00adc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

#### 1.41.1 - 2023/12/19
### Changed
- When building a Spring `ResponseEntity` with an explicit status, provide an integer derived from the `HttpStatus` enum, rather than providing the
`HttpStatus` directly, to handle binary incompatibility between Spring 5 and 6 causing NoSuchMethod errors when tw-tasks is used with Spring 6

#### 1.41.0 - 2023/11/16
### Added
- Added `taskType` and `taskSubType` parameters to management query endpoints.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.41.0
version=1.41.1
org.gradle.internal.http.socketTimeout=120000
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected <T> T callWithAuthentication(Set<String> roles, Function<Authenticatio
final Authentication auth = getAuthenticationIfAllowed(roles);

if (auth == null) {
return (T) ResponseEntity.status(HttpStatus.FORBIDDEN).build();
return (T) ResponseEntity.status(HttpStatus.FORBIDDEN.value()).build();
}

return fun.apply(auth);
Expand Down

0 comments on commit a00adc6

Please sign in to comment.