Updated GF, Jetty, Mimepull, Moxy, Yasson dependencies (#4425) * Updated GF, Jetty, Mimepull, Moxy, Yasson dependencies Signed-off-by: Jan Supol <jan.supol@oracle.com>
diff --git a/containers/jetty-http/src/main/java/org/glassfish/jersey/jetty/JettyHttpContainer.java b/containers/jetty-http/src/main/java/org/glassfish/jersey/jetty/JettyHttpContainer.java index 6b7282f..5a57c72 100644 --- a/containers/jetty-http/src/main/java/org/glassfish/jersey/jetty/JettyHttpContainer.java +++ b/containers/jetty-http/src/main/java/org/glassfish/jersey/jetty/JettyHttpContainer.java
@@ -18,6 +18,8 @@ import java.io.IOException; import java.io.OutputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.lang.reflect.Type; import java.net.URI; import java.net.URISyntaxException; @@ -323,7 +325,7 @@ @Override public void commit() { try { - response.closeOutput(); + closeOutput(response); } catch (final IOException e) { LOGGER.log(Level.WARNING, LocalizationMessages.UNABLE_TO_CLOSE_RESPONSE(), e); } finally { @@ -334,6 +336,22 @@ } } + private void closeOutput(Response response) throws IOException { + try { + response.completeOutput(); + } catch (final IOException e) { + throw e; + } catch (NoSuchMethodError e) { + // try older Jetty Response#closeOutput + try { + Method method = response.getClass().getMethod("closeOutput"); + method.invoke(response); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { + throw new IOException(ex); + } + } + } + @Override public void failure(final Throwable error) { try {
diff --git a/pom.xml b/pom.xml index 709de8e..6710e7d 100644 --- a/pom.xml +++ b/pom.xml
@@ -1954,6 +1954,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>${junit5.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.6</version> @@ -2073,7 +2079,6 @@ <checkstyle.version>8.28</checkstyle.version> <easymock.version>3.3</easymock.version> <ejb.version>3.2.5</ejb.version> - <gf.impl.version>5.1.0-RC2</gf.impl.version> <fasterxml.classmate.version>1.3.3</fasterxml.classmate.version> <findbugs.glassfish.version>1.7</findbugs.glassfish.version> <findbugs.version>3.0.4</findbugs.version> @@ -2090,45 +2095,21 @@ <hk2.jvnet.osgi.version>org.jvnet.hk2.*;version="[2.5,4)"</hk2.jvnet.osgi.version> <hk2.config.version>5.1.0</hk2.config.version> <httpclient.version>4.5.9</httpclient.version> - <istack.commons.runtime.version>3.0.8</istack.commons.runtime.version> <jackson.version>2.10.1</jackson.version> <jackson1.version>1.9.13</jackson1.version> - <jakarta.activation-api.version>2.0.0-RC3</jakarta.activation-api.version> - <jakarta.activation.version>2.0.0-RC3</jakarta.activation.version> <javassist.version>3.25.0-GA</javassist.version> - <javax.annotation.osgi.version>javax.annotation.*;version="[1.2,3)"</javax.annotation.osgi.version> - <jakarta.annotation.osgi.version>jakarta.annotation.*;version="[1.2,3)"</jakarta.annotation.osgi.version> - <jakarta.annotation.version>2.0.0-RC1</jakarta.annotation.version> - <javax.annotation.version>1.3.5</javax.annotation.version> - <javax.el.version>3.0.3</javax.el.version> - <javax.el.impl.version>3.0.2</javax.el.impl.version> - <javax.interceptor.version>1.2.5</javax.interceptor.version> - <javax.persistence.version>2.2.3</javax.persistence.version> - <javax.validation.api.version>2.0.2</javax.validation.api.version> - <jaxb.api.version>3.0.0-RC2</jaxb.api.version> - <javax.jaxb.api.version>2.3.2</javax.jaxb.api.version> - <jaxb.ri.version>3.0.0-M1</jaxb.ri.version> - <jsonb.api.version>1.0.2</jsonb.api.version> - <jaxrs.api.spec.version>3.0</jaxrs.api.spec.version> - <jaxrs.api.impl.version>3.0.0-M1</jaxrs.api.impl.version> <jboss.logging.version>3.3.0.Final</jboss.logging.version> <jersey1.version>1.19.3</jersey1.version> <jersey1.last.final.version>${jersey1.version}</jersey1.last.final.version> <jettison.version>1.3.7</jettison.version> <!-- TODO: 1.3.8 doesn't work; AbstractJsonTest complexBeanWithAttributes --> - <jetty.plugin.version>6.1.26</jetty.plugin.version> - <jetty.version>9.4.17.v20190418</jetty.version> - <jetty.servlet.api.25.version>6.1.14</jetty.servlet.api.25.version> <jmh.version>1.10.2</jmh.version> <jmockit.version>1.44</jmockit.version> - <jsonp.ri.version>1.1.5</jsonp.ri.version> - <jsonp.jaxrs.version>1.1.5</jsonp.jaxrs.version> <jsp.version>2.3.6</jsp.version> <jstl.version>1.2.7</jstl.version> <jta.api.version>1.3.3</jta.api.version> + <junit5.version>5.6.0</junit5.version> <kryo.version>4.0.1</kryo.version> - <mimepull.version>1.9.11</mimepull.version> <mockito.version>1.10.19</mockito.version> - <moxy.version>2.7.4</moxy.version> <mustache.version>0.8.17</mustache.version> <netty.version>4.1.43.Final</netty.version> <nexus-staging.mvn.plugin.version>1.6.7</nexus-staging.mvn.plugin.version> @@ -2153,6 +2134,34 @@ <weld.version>2.2.14.Final</weld.version> <!-- 2.4.1 doesn't work - bv tests --> <weld3.version>3.0.0.Final</weld3.version> <xerces.version>2.11.0</xerces.version> - <yasson.version>1.0.3</yasson.version> + + <!-- do not need CQs --> + <gf.impl.version>5.1.0</gf.impl.version> + <istack.commons.runtime.version>3.0.8</istack.commons.runtime.version> + <jakarta.activation-api.version>2.0.0-RC3</jakarta.activation-api.version> + <jakarta.activation.version>2.0.0-RC3</jakarta.activation.version> + <javax.el.version>3.0.3</javax.el.version> + <javax.el.impl.version>3.0.3</javax.el.impl.version> + <javax.annotation.osgi.version>javax.annotation.*;version="[1.2,3)"</javax.annotation.osgi.version> + <jakarta.annotation.osgi.version>jakarta.annotation.*;version="[1.2,3)"</jakarta.annotation.osgi.version> + <jakarta.annotation.version>2.0.0-RC1</jakarta.annotation.version> + <javax.annotation.version>1.3.5</javax.annotation.version> + <javax.interceptor.version>1.2.5</javax.interceptor.version> + <javax.persistence.version>2.2.3</javax.persistence.version> + <javax.validation.api.version>2.0.2</javax.validation.api.version> + <jaxb.api.version>3.0.0-RC2</jaxb.api.version> + <javax.jaxb.api.version>2.3.2</javax.jaxb.api.version> + <jaxb.ri.version>3.0.0-M1</jaxb.ri.version> + <jaxrs.api.spec.version>3.0</jaxrs.api.spec.version> + <jaxrs.api.impl.version>3.0.0-M1</jaxrs.api.impl.version> + <jetty.plugin.version>6.1.26</jetty.plugin.version> + <jetty.version>9.4.27.v20200227</jetty.version> + <jetty.servlet.api.25.version>6.1.14</jetty.servlet.api.25.version> + <jsonb.api.version>1.0.2</jsonb.api.version> + <jsonp.ri.version>1.1.6</jsonp.ri.version> + <jsonp.jaxrs.version>1.1.6</jsonp.jaxrs.version> + <mimepull.version>1.9.13</mimepull.version> + <moxy.version>2.7.6</moxy.version> + <yasson.version>1.0.6</yasson.version> </properties> </project>
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/entity/ComplexBeanWithAttributes4.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/entity/ComplexBeanWithAttributes4.java index f14c9c7..660a6e2 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/entity/ComplexBeanWithAttributes4.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/entity/ComplexBeanWithAttributes4.java
@@ -86,7 +86,7 @@ public int hashCode() { int hash = 3; hash = 19 * hash + (this.a1 != null ? this.a1.hashCode() : 0); - hash = 19 * hash + this.a2; + hash = 19 * hash + (this.a2 != null ? this.a2.hashCode() : 0); hash = 19 * hash + (this.b != null ? this.b.hashCode() : 0); hash = 19 * hash + (this.filler1 != null ? this.filler1.hashCode() : 0); hash = 19 * hash + (this.filler2 != null ? this.filler2.hashCode() : 0);
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/entity/SimpleBeanWithObjectAttributes.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/entity/SimpleBeanWithObjectAttributes.java index 4cea599..5dc1d2a 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/entity/SimpleBeanWithObjectAttributes.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/entity/SimpleBeanWithObjectAttributes.java
@@ -80,7 +80,9 @@ if (null != uri) { hash += 17 * uri.hashCode(); } - hash += 13 * i; + if (null != i) { + hash += 13 * i; + } return hash; }
diff --git a/tests/integration/jetty-response-close/pom.xml b/tests/integration/jetty-response-close/pom.xml new file mode 100644 index 0000000..b6e9c34 --- /dev/null +++ b/tests/integration/jetty-response-close/pom.xml
@@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> +<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/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>project</artifactId> + <groupId>org.glassfish.jersey.tests.integration</groupId> + <version>2.31-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>jetty-response-close</artifactId> + + <dependencies> + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-jetty-http</artifactId> + <version>${project.version}</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + <!-- Test Backward compatibility with this version --> + <version>9.4.17.v20190418</version> + </dependency> + + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <properties> + <surefire.security.argline>-Djava.security.manager -Djava.security.policy=${project.build.directory}/test-classes/surefire.policy</surefire.security.argline> + </properties> + +</project> \ No newline at end of file
diff --git a/tests/integration/jetty-response-close/src/main/java/org/glassfish/jersey/tests/jettyresponseclose/Resource.java b/tests/integration/jetty-response-close/src/main/java/org/glassfish/jersey/tests/jettyresponseclose/Resource.java new file mode 100644 index 0000000..9ab1e33 --- /dev/null +++ b/tests/integration/jetty-response-close/src/main/java/org/glassfish/jersey/tests/jettyresponseclose/Resource.java
@@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.jersey.tests.jettyresponseclose; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +@Path("/") +public class Resource { + @GET + public String get() { + return Resource.class.getName(); + } +}
diff --git a/tests/integration/jetty-response-close/src/test/java/org/glassfish/jersey/tests/jettyresponseclose/JettyHttpContainerCloseTest.java b/tests/integration/jetty-response-close/src/test/java/org/glassfish/jersey/tests/jettyresponseclose/JettyHttpContainerCloseTest.java new file mode 100644 index 0000000..eb8a3ca --- /dev/null +++ b/tests/integration/jetty-response-close/src/test/java/org/glassfish/jersey/tests/jettyresponseclose/JettyHttpContainerCloseTest.java
@@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.jersey.tests.jettyresponseclose; + +import org.eclipse.jetty.server.Server; +import org.glassfish.jersey.jetty.JettyHttpContainer; +import org.glassfish.jersey.jetty.JettyHttpContainerFactory; +import org.glassfish.jersey.server.ResourceConfig; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.core.Response; +import java.net.URI; + +public class JettyHttpContainerCloseTest { + + private static Server server; + private static JettyHttpContainer container; + private static final String URL = "http://localhost:9080"; + + @BeforeAll + public static void setup() { + server = JettyHttpContainerFactory.createServer(URI.create(URL), + new ResourceConfig(Resource.class)); + container = (JettyHttpContainer) server.getHandler(); + } + + @AfterAll + public static void teardown() throws Exception { + container.doStop(); + } + + @Test + public void testResponseClose() { + try (Response response = ClientBuilder.newClient().target(URL).request().get()) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(Resource.class.getName(), response.readEntity(String.class)); + + } + } +}
diff --git a/tests/integration/jetty-response-close/src/test/resources/surefire.policy b/tests/integration/jetty-response-close/src/test/resources/surefire.policy new file mode 100644 index 0000000..f012633 --- /dev/null +++ b/tests/integration/jetty-response-close/src/test/resources/surefire.policy
@@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +// we do not care about java lib itself +grant codebase "file:${java.home}/-" { + permission java.security.AllPermission; +}; + +// we do not care about our dependencies +grant codebase "file:${settings.localRepository}/-" { + permission java.security.AllPermission; +}; + +grant codebase "file:${user.home}/-" { + permission java.io.FilePermission "<<ALL FILES>>", "read"; +}; + +grant { + permission java.lang.management.ManagementPermission "monitor"; + permission java.util.PropertyPermission "*", "read, write"; + permission java.util.logging.LoggingPermission "control"; + permission java.lang.RuntimePermission "setIO"; + permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; + + permission java.lang.RuntimePermission "accessDeclaredMembers"; + permission java.lang.RuntimePermission "modifyThread"; + permission java.io.FilePermission "<<ALL FILES>>", "read"; + + permission java.lang.RuntimePermission "getenv.JETTY_AVAILABLE_PROCESSORS"; + permission java.net.SocketPermission "localhost", "accept,connect,listen,resolve"; + permission java.lang.RuntimePermission "setContextClassLoader"; +};
diff --git a/tests/integration/pom.xml b/tests/integration/pom.xml index 3a86fb2..877bcac 100644 --- a/tests/integration/pom.xml +++ b/tests/integration/pom.xml
@@ -84,8 +84,7 @@ <module>jersey-3992</module> <module>jersey-4099</module> <module>jersey-4321</module> -<!-- <module>portability-jersey-1</module>--> -<!-- <module>portability-jersey-2</module>--> + <module>jetty-response-close</module> <module>microprofile</module> <module>portability-jersey-1</module> <module>portability-jersey-2</module>