Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion org.restlet.ext.crypto/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;

Expand Down
2 changes: 1 addition & 1 deletion org.restlet.ext.freemarker/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;
Expand Down
2 changes: 1 addition & 1 deletion org.restlet.ext.gson/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;
Expand Down
2 changes: 1 addition & 1 deletion org.restlet.ext.jaas/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;

Expand Down
2 changes: 1 addition & 1 deletion org.restlet.ext.jackson/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Invoice> invoices = new CopyOnWriteArrayList<Invoice>();
private CopyOnWriteArrayList<Invoice> invoices = new CopyOnWriteArrayList<Invoice>();

public String getFirstName() {
return firstName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
*/
package org.restlet.ext.jackson;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

public class Invoice {
public class Invoice implements Serializable {

@Serial private static final long serialVersionUID = 1L;

private Date date;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Date;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -89,6 +93,25 @@ void testException() throws Exception {
assertEquals(me, rep.getObject());
}

@Test
void testExceptionJavaSerialization() throws Exception {
MyException exception = new MyException(createCustomer(), "CUST-1234");
exception.setStackTrace(new StackTraceElement[0]);

ByteArrayOutputStream bytes = new ByteArrayOutputStream();
try (ObjectOutputStream output = new ObjectOutputStream(bytes)) {
output.writeObject(exception);
}

MyException copy;
try (ObjectInputStream input =
new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) {
copy = (MyException) input.readObject();
}

assertEquals(exception, copy);
}

@Test
void testJson() throws Exception {
Customer customer = createCustomer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class MyException extends Exception {

@Serial private static final long serialVersionUID = 1L;

@SuppressWarnings("serial")
private Customer customer;

private String errorCode;
Expand Down
2 changes: 1 addition & 1 deletion org.restlet.ext.json/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;
Expand Down
4 changes: 4 additions & 0 deletions org.restlet.ext.openapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion org.restlet.ext.openapi/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
*
* <p>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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion org.restlet.ext.slf4j/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;
Expand Down
2 changes: 1 addition & 1 deletion org.restlet.ext.spring/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
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));

Check warning on line 104 in org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringResourceTestCase.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use assertNotEquals instead.

See more on https://sonarcloud.io/project/issues?id=restlet_restlet-framework-java&issues=AaFa5-VEhqP9LspQXiFD&open=AaFa5-VEhqP9LspQXiFD&pullRequest=1551
}
}
2 changes: 1 addition & 1 deletion org.restlet.ext.thymeleaf/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* <p>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;
Expand Down
65 changes: 65 additions & 0 deletions org.restlet.ext.websocket/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.restlet</groupId>
<artifactId>org.restlet.parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>org.restlet.ext.websocket</artifactId>
<name>Restlet Framework - WebSocket extension</name>
<description>Support for WebSocket servers and clients (experimental), on the Netty connectors.</description>

<dependencies>
<dependency>
<groupId>org.restlet</groupId>
<artifactId>org.restlet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${lib-junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>m2e-test-modules</id>
<activation>
<property><name>m2e.version</name></property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-testCompile</id>
<configuration>
<!-- Keep the JDK HTTP client test-only in m2e/JDT;
Maven already compiles tests on the classpath. -->
<compilerArgs combine.children="append">
<arg>--add-reads</arg>
<arg>org.restlet.ext.websocket=java.net.http</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading
Loading