Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated GF, Jetty, Mimepull, Moxy, Yasson dependencies #4425

Merged
merged 2 commits into from
Apr 2, 2020
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
Expand All @@ -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;
Expand Down Expand Up @@ -323,7 +325,7 @@ public void setSuspendTimeout(final long timeOut, final TimeUnit timeUnit) throw
@Override
public void commit() {
try {
response.closeOutput();
closeOutput(response);
} catch (final IOException e) {
LOGGER.log(Level.WARNING, LocalizationMessages.UNABLE_TO_CLOSE_RESPONSE(), e);
} finally {
Expand All @@ -334,6 +336,22 @@ public void commit() {
}
}

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 {
Expand Down
55 changes: 32 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1960,6 +1960,12 @@
<version>4.12</version>
<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>
Expand Down Expand Up @@ -2080,7 +2086,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>
Expand All @@ -2097,41 +2102,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.version>1.2.1</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>
<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>2.3.2</jaxb.api.version>
<jaxb.ri.version>2.3.2</jaxb.ri.version>
<jsonb.api.version>1.0.2</jsonb.api.version>
<jaxrs.api.spec.version>2.1</jaxrs.api.spec.version>
<jaxrs.api.impl.version>2.1.6</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>
Expand All @@ -2156,6 +2141,30 @@
<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.version>1.2.2</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>
<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>2.3.2</jaxb.api.version>
<jaxb.ri.version>2.3.2</jaxb.ri.version>
<jaxrs.api.spec.version>2.1</jaxrs.api.spec.version>
<jaxrs.api.impl.version>2.1.6</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>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
Expand Down Expand Up @@ -86,7 +86,7 @@ public boolean equals(Object obj) {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
Expand Down Expand Up @@ -80,7 +80,9 @@ public int hashCode() {
if (null != uri) {
hash += 17 * uri.hashCode();
}
hash += 13 * i;
if (null != i) {
hash += 13 * i;
}
return hash;
}

Expand Down
62 changes: 62 additions & 0 deletions tests/integration/jetty-response-close/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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));

}
}
}
Original file line number Diff line number Diff line change
@@ -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";
};
1 change: 1 addition & 0 deletions tests/integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<module>jersey-3992</module>
<module>jersey-4099</module>
<module>jersey-4321</module>
<module>jetty-response-close</module>
<module>microprofile</module>
<module>portability-jersey-1</module>
<module>portability-jersey-2</module>
Expand Down