From ef9cb96ef2c0d0ce7221dd7d7e9afc10677f2587 Mon Sep 17 00:00:00 2001 From: Marco Brandizi Date: Mon, 31 Jul 2023 16:41:51 +0100 Subject: [PATCH] Upgrading Spring dependency and preparing release 13.0. --- pom.xml | 10 +++++----- revision-history.md | 11 +++++++---- .../ebi/utils/opt/net/ConfigBootstrapWebListener.java | 6 +++--- .../exceptions/ResponseStatusException2.java | 8 +++++++- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index f9ffd9ba5..8c1b0408a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ uk.ac.ebi jutils - 12.0.1-SNAPSHOT + 13.0-SNAPSHOT JUtils - Miscellanea of Java Utils @@ -142,7 +142,7 @@ org.springframework spring-web - 5.3.25 + 6.0.11 true @@ -158,9 +158,9 @@ - javax.servlet - javax.servlet-api - 4.0.1 + jakarta.servlet + jakarta.servlet-api + 6.0.0 true diff --git a/revision-history.md b/revision-history.md index 2037fa516..260f955d0 100644 --- a/revision-history.md +++ b/revision-history.md @@ -1,12 +1,15 @@ # Revision History -*This file was last revised on 2023-07-26*. **Please keep this note updated**. +*This file was last revised on 2023-07-31*. **Please keep this note updated**. -## 12.0.1-SNAPSHOT -* Current snapshot +## 13.0.1-SNAPSHOT +## 13.0 +* **These migrations are incompatible with older versions**: + * `javax.servlet-api` migrated to `jakarta.servlet-api`. + * `spring-web` moved to 6.0. -## 12.0-SNAPSHOT +## 12.0 * Migration to Java 17. **No backward compatibility guaranteed**. ## 11.1.1 diff --git a/src/main/java/uk/ac/ebi/utils/opt/net/ConfigBootstrapWebListener.java b/src/main/java/uk/ac/ebi/utils/opt/net/ConfigBootstrapWebListener.java index 02f0fa7c9..e8a338420 100644 --- a/src/main/java/uk/ac/ebi/utils/opt/net/ConfigBootstrapWebListener.java +++ b/src/main/java/uk/ac/ebi/utils/opt/net/ConfigBootstrapWebListener.java @@ -3,8 +3,8 @@ import java.util.HashMap; import java.util.Map; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; +import jakarta.servlet.ServletContextEvent; +import jakarta.servlet.ServletContextListener; import uk.ac.ebi.utils.collections.OptionsMap; @@ -54,7 +54,7 @@ public void contextInitialized ( ServletContextEvent sce ) @Override public void contextDestroyed ( ServletContextEvent sce ) { - // Does nothing, added just for compatibility with older servlet APIs. + // Does nothing, added just for compatibility with servlet APIs. } diff --git a/src/main/java/uk/ac/ebi/utils/opt/springweb/exceptions/ResponseStatusException2.java b/src/main/java/uk/ac/ebi/utils/opt/springweb/exceptions/ResponseStatusException2.java index 09c62c933..514904604 100644 --- a/src/main/java/uk/ac/ebi/utils/opt/springweb/exceptions/ResponseStatusException2.java +++ b/src/main/java/uk/ac/ebi/utils/opt/springweb/exceptions/ResponseStatusException2.java @@ -3,6 +3,7 @@ import java.util.Optional; import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.web.server.ResponseStatusException; /** @@ -54,7 +55,12 @@ public ResponseStatusException2 ( int rawStatusCode, String reason, Throwable ca */ public String getMessage () { - int code = this.getRawStatusCode (); + HttpStatusCode statusCode = Optional.ofNullable ( this.getStatusCode () ) + .orElse ( HttpStatus.INTERNAL_SERVER_ERROR ); + + int code = statusCode.value (); + + // Finding a reason with Spring >= 6 HttpStatus status = HttpStatus.resolve ( code ); String codeStr = "HTTP " +