From 57117c69b7f3b47b61be4f7968197936af8398e6 Mon Sep 17 00:00:00 2001 From: Jerome Louvel <374450+jlouvel@users.noreply.github.com> Date: Tue, 20 Oct 2026 11:41:11 -0400 Subject: [PATCH] fix: improve 3.0 build compatibility and resource cleanup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- changes.md | 3 + .../src/main/java/module-info.java | 2 +- .../src/main/java/module-info.java | 2 +- .../src/main/java/module-info.java | 2 +- .../src/main/java/module-info.java | 2 +- .../src/main/java/module-info.java | 2 +- .../org/restlet/ext/jackson/Customer.java | 8 ++- .../java/org/restlet/ext/jackson/Invoice.java | 6 +- .../restlet/ext/jackson/JacksonTestCase.java | 23 +++++++ .../org/restlet/ext/jackson/MyException.java | 1 - .../src/main/java/module-info.java | 2 +- org.restlet.ext.openapi/pom.xml | 4 ++ .../src/main/java/module-info.java | 3 +- .../ext/openapi/OpenApiGenerationTest.java | 15 ++++- .../src/main/java/module-info.java | 2 +- .../src/main/java/module-info.java | 2 +- .../ext/spring/SpringContextTestCase.java | 62 +++++++++--------- .../ext/spring/SpringResourceTestCase.java | 3 +- .../src/main/java/module-info.java | 2 +- org.restlet.ext.websocket/pom.xml | 65 +++++++++++++++++++ .../src/main/java/module-info.java | 2 +- org.restlet/pom.xml | 28 +++++++- .../application/DecodeRepresentation.java | 22 ++++++- .../application/EncodeRepresentation.java | 17 +++-- .../engine/converter/DefaultConverter.java | 16 ++--- .../EncodeRepresentationTestCase.java | 9 +-- .../engine/connector/AsyncTestCase.java | 10 +-- .../engine/io/WriterOutputStreamTestCase.java | 36 +++++----- .../resource/AnnotatedResource13TestCase.java | 2 +- .../restlet/service/TaskServiceTestCase.java | 2 - 30 files changed, 262 insertions(+), 93 deletions(-) create mode 100644 org.restlet.ext.websocket/pom.xml diff --git a/changes.md b/changes.md index 4552c900c6..b17e9584ee 100644 --- a/changes.md +++ b/changes.md @@ -80,9 +80,12 @@ Changes log to lowercase at the HTTP boundary. - Added the `Protocol.STDIO` pseudo-protocol constant for standard input/output connectors. - Bugs fixed + - Fixed the OpenAPI extension build path for Commons Lang types inherited from Swagger. - Slf4j bridge reports wrong line number and caller class in log4j. Issue #233. - When GET is an allowed method of a server resource, HEAD is now also listed (e.g. in the Allow header of a 405 response). Issue #266. - Misc + - Fixed JDK HTTP client accessibility in core and WebSocket tests in Eclipse and VS Code, + without adding a production module dependency. - Pinned the Maven Deploy plugin to version 3.2.0 (avoids resolving incompatible Maven 4 beta versions). - Added Netty 4.2.19 (imported with the `netty-bom`). CI builds with Java 25. - The `dangling-doc-comments` lint, new in Java 23, is disabled because license headers diff --git a/org.restlet.ext.crypto/src/main/java/module-info.java b/org.restlet.ext.crypto/src/main/java/module-info.java index efd900c5b0..d25b1c35ac 100644 --- a/org.restlet.ext.crypto/src/main/java/module-info.java +++ b/org.restlet.ext.crypto/src/main/java/module-info.java @@ -6,7 +6,7 @@ * *
Restlet is a registered trademark of QlikTech International AB. */ -@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"}) +@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"}) module org.restlet.ext.crypto { requires transitive org.restlet; diff --git a/org.restlet.ext.freemarker/src/main/java/module-info.java b/org.restlet.ext.freemarker/src/main/java/module-info.java index cc9a42f605..c0dc206cdd 100644 --- a/org.restlet.ext.freemarker/src/main/java/module-info.java +++ b/org.restlet.ext.freemarker/src/main/java/module-info.java @@ -6,7 +6,7 @@ * *
Restlet is a registered trademark of QlikTech International AB. */ -@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"}) +@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"}) module org.restlet.ext.freemarker { requires transitive org.restlet; requires transitive freemarker; diff --git a/org.restlet.ext.gson/src/main/java/module-info.java b/org.restlet.ext.gson/src/main/java/module-info.java index f41bc78697..81da599a44 100644 --- a/org.restlet.ext.gson/src/main/java/module-info.java +++ b/org.restlet.ext.gson/src/main/java/module-info.java @@ -6,7 +6,7 @@ * *
Restlet is a registered trademark of QlikTech International AB. */ -@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"}) +@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"}) module org.restlet.ext.gson { requires transitive org.restlet; requires transitive com.google.gson; diff --git a/org.restlet.ext.jaas/src/main/java/module-info.java b/org.restlet.ext.jaas/src/main/java/module-info.java index f880141efa..e7c4b44129 100644 --- a/org.restlet.ext.jaas/src/main/java/module-info.java +++ b/org.restlet.ext.jaas/src/main/java/module-info.java @@ -6,7 +6,7 @@ * *
Restlet is a registered trademark of QlikTech International AB. */ -@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"}) +@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"}) module org.restlet.ext.jaas { requires transitive org.restlet; diff --git a/org.restlet.ext.jackson/src/main/java/module-info.java b/org.restlet.ext.jackson/src/main/java/module-info.java index db8759f1c2..b06d67e757 100644 --- a/org.restlet.ext.jackson/src/main/java/module-info.java +++ b/org.restlet.ext.jackson/src/main/java/module-info.java @@ -6,7 +6,7 @@ * *
Restlet is a registered trademark of QlikTech International AB.
*/
-@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"})
+@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
module org.restlet.ext.jackson {
requires transitive org.restlet;
requires tools.jackson.core;
diff --git a/org.restlet.ext.jackson/src/test/java/org/restlet/ext/jackson/Customer.java b/org.restlet.ext.jackson/src/test/java/org/restlet/ext/jackson/Customer.java
index 4c7873fb7b..506d7711b6 100644
--- a/org.restlet.ext.jackson/src/test/java/org/restlet/ext/jackson/Customer.java
+++ b/org.restlet.ext.jackson/src/test/java/org/restlet/ext/jackson/Customer.java
@@ -8,16 +8,20 @@
*/
package org.restlet.ext.jackson;
+import java.io.Serial;
+import java.io.Serializable;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
-public class Customer {
+public class Customer implements Serializable {
+
+ @Serial private static final long serialVersionUID = 1L;
private String firstName;
private String lastName;
- private List Restlet is a registered trademark of QlikTech International AB.
*/
-@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"})
+@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
module org.restlet.ext.json {
requires transitive org.restlet;
requires transitive org.json;
diff --git a/org.restlet.ext.openapi/pom.xml b/org.restlet.ext.openapi/pom.xml
index 5d6480f921..4e1d38ce3c 100644
--- a/org.restlet.ext.openapi/pom.xml
+++ b/org.restlet.ext.openapi/pom.xml
@@ -33,6 +33,10 @@
Restlet is a registered trademark of QlikTech International AB.
*/
-@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"})
+@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
module org.restlet.ext.openapi {
requires transitive org.restlet;
+ requires org.apache.commons.lang3;
requires io.swagger.v3.core;
requires io.swagger.v3.oas.models;
requires io.swagger.v3.oas.integration;
diff --git a/org.restlet.ext.openapi/src/test/java/org/restlet/ext/openapi/OpenApiGenerationTest.java b/org.restlet.ext.openapi/src/test/java/org/restlet/ext/openapi/OpenApiGenerationTest.java
index fff9e4114b..4d5577c689 100644
--- a/org.restlet.ext.openapi/src/test/java/org/restlet/ext/openapi/OpenApiGenerationTest.java
+++ b/org.restlet.ext.openapi/src/test/java/org/restlet/ext/openapi/OpenApiGenerationTest.java
@@ -14,7 +14,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import java.util.stream.Stream;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -36,7 +35,19 @@
import org.restlet.resource.ClientResource;
class OpenApiGenerationTest {
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory());
+ private static final ObjectMapper OBJECT_MAPPER = createYamlMapper();
+
+ private static ObjectMapper createYamlMapper() {
+ try {
+ var yamlFactory =
+ Class.forName("com.fasterxml.jackson.dataformat.yaml.YAMLFactory")
+ .getConstructor()
+ .newInstance();
+ return new ObjectMapper((com.fasterxml.jackson.core.JsonFactory) yamlFactory);
+ } catch (ReflectiveOperationException e) {
+ throw new IllegalStateException("Unable to initialize the YAML parser", e);
+ }
+ }
Component component;
Server server;
diff --git a/org.restlet.ext.slf4j/src/main/java/module-info.java b/org.restlet.ext.slf4j/src/main/java/module-info.java
index 671f769f79..f49a6e3861 100644
--- a/org.restlet.ext.slf4j/src/main/java/module-info.java
+++ b/org.restlet.ext.slf4j/src/main/java/module-info.java
@@ -6,7 +6,7 @@
*
* Restlet is a registered trademark of QlikTech International AB.
*/
-@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"})
+@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
module org.restlet.ext.slf4j {
requires transitive org.restlet;
requires transitive org.slf4j;
diff --git a/org.restlet.ext.spring/src/main/java/module-info.java b/org.restlet.ext.spring/src/main/java/module-info.java
index 7f109d4d61..6e9639f7a5 100644
--- a/org.restlet.ext.spring/src/main/java/module-info.java
+++ b/org.restlet.ext.spring/src/main/java/module-info.java
@@ -6,7 +6,7 @@
*
* Restlet is a registered trademark of QlikTech International AB.
*/
-@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"})
+@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
module org.restlet.ext.spring {
requires transitive org.restlet;
requires transitive spring.beans;
diff --git a/org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringContextTestCase.java b/org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringContextTestCase.java
index 23f0e90960..6efa5c4341 100644
--- a/org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringContextTestCase.java
+++ b/org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringContextTestCase.java
@@ -30,56 +30,60 @@ private Context restletContextWithClapDispatcher() {
@Test
void getRestletContext_returnsConstructorArgument() {
Context restletContext = new Context();
- SpringContext springContext = new SpringContext(restletContext);
- assertSame(restletContext, springContext.getRestletContext());
+ try (SpringContext springContext = new SpringContext(restletContext)) {
+ assertSame(restletContext, springContext.getRestletContext());
+ }
}
@Test
void getPropertyConfigRefs_lazyInitializesToEmptyModifiableList() {
- SpringContext springContext = new SpringContext(new Context());
- assertNotNull(springContext.getPropertyConfigRefs());
- assertTrue(springContext.getPropertyConfigRefs().isEmpty());
- springContext.getPropertyConfigRefs().add("some-ref");
- assertEquals(1, springContext.getPropertyConfigRefs().size());
+ try (SpringContext springContext = new SpringContext(new Context())) {
+ assertNotNull(springContext.getPropertyConfigRefs());
+ assertTrue(springContext.getPropertyConfigRefs().isEmpty());
+ springContext.getPropertyConfigRefs().add("some-ref");
+ assertEquals(1, springContext.getPropertyConfigRefs().size());
+ }
}
@Test
void getXmlConfigRefs_lazyInitializesToEmptyModifiableList() {
- SpringContext springContext = new SpringContext(new Context());
- assertNotNull(springContext.getXmlConfigRefs());
- assertTrue(springContext.getXmlConfigRefs().isEmpty());
- springContext.getXmlConfigRefs().add("some-ref");
- assertEquals(1, springContext.getXmlConfigRefs().size());
+ try (SpringContext springContext = new SpringContext(new Context())) {
+ assertNotNull(springContext.getXmlConfigRefs());
+ assertTrue(springContext.getXmlConfigRefs().isEmpty());
+ springContext.getXmlConfigRefs().add("some-ref");
+ assertEquals(1, springContext.getXmlConfigRefs().size());
+ }
}
@Test
void refresh_withoutConfigRefs_refreshesEmptyContext() {
- SpringContext springContext = new SpringContext(new Context());
- springContext.refresh();
- assertTrue(springContext.isActive());
+ try (SpringContext springContext = new SpringContext(new Context())) {
+ springContext.refresh();
+ assertTrue(springContext.isActive());
+ }
}
@Test
void refresh_withPropertyConfigRef_loadsBeanDefinitionsFromProperties() {
- SpringContext springContext = new SpringContext(restletContextWithClapDispatcher());
- springContext
- .getPropertyConfigRefs()
- .add("clap://class/org/restlet/ext/spring/SpringContextTestCase.properties");
+ try (SpringContext springContext = new SpringContext(restletContextWithClapDispatcher())) {
+ springContext
+ .getPropertyConfigRefs()
+ .add("clap://class/org/restlet/ext/spring/SpringContextTestCase.properties");
+ springContext.refresh();
- springContext.refresh();
-
- assertNotNull(springContext.getBean("myPropertyBean"));
+ assertNotNull(springContext.getBean("myPropertyBean"));
+ }
}
@Test
void refresh_withXmlConfigRef_loadsBeanDefinitionsFromXml() {
- SpringContext springContext = new SpringContext(restletContextWithClapDispatcher());
- springContext
- .getXmlConfigRefs()
- .add("clap://class/org/restlet/ext/spring/SpringContextTestCase.xml");
-
- springContext.refresh();
+ try (SpringContext springContext = new SpringContext(restletContextWithClapDispatcher())) {
+ springContext
+ .getXmlConfigRefs()
+ .add("clap://class/org/restlet/ext/spring/SpringContextTestCase.xml");
+ springContext.refresh();
- assertNotNull(springContext.getBean("myXmlBean"));
+ assertNotNull(springContext.getBean("myXmlBean"));
+ }
}
}
diff --git a/org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringResourceTestCase.java b/org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringResourceTestCase.java
index e219334b7c..0efcddb87f 100644
--- a/org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringResourceTestCase.java
+++ b/org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringResourceTestCase.java
@@ -100,6 +100,7 @@ void equalsAndHashCode_basedOnWrappedRepresentation() {
assertEquals(resource1, resource2);
assertEquals(resource1.hashCode(), resource2.hashCode());
assertNotEquals(resource1, resource3);
- assertFalse(resource1.equals("not a resource"));
+ Object notAResource = "not a resource";
+ assertFalse(resource1.equals(notAResource));
}
}
diff --git a/org.restlet.ext.thymeleaf/src/main/java/module-info.java b/org.restlet.ext.thymeleaf/src/main/java/module-info.java
index ecb5d2d03d..58900eed72 100644
--- a/org.restlet.ext.thymeleaf/src/main/java/module-info.java
+++ b/org.restlet.ext.thymeleaf/src/main/java/module-info.java
@@ -6,7 +6,7 @@
*
* Restlet is a registered trademark of QlikTech International AB.
*/
-@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"})
+@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
module org.restlet.ext.thymeleaf {
requires transitive org.restlet;
requires transitive thymeleaf;
diff --git a/org.restlet.ext.websocket/pom.xml b/org.restlet.ext.websocket/pom.xml
new file mode 100644
index 0000000000..12f5447c70
--- /dev/null
+++ b/org.restlet.ext.websocket/pom.xml
@@ -0,0 +1,65 @@
+
+ Restlet is a registered trademark of QlikTech International AB.
*/
-@SuppressWarnings({"module", "requires-automatic", "requires-transitive-automatic"})
+@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
module org.restlet.ext.xml {
requires transitive org.restlet;
requires java.xml;
diff --git a/org.restlet/pom.xml b/org.restlet/pom.xml
index a41c5dcfb2..c9017eb4be 100644
--- a/org.restlet/pom.xml
+++ b/org.restlet/pom.xml
@@ -134,8 +134,34 @@
-