Skip to content

Commit

Permalink
JDK16 Support (#4785)
Browse files Browse the repository at this point in the history
* JDK16 Support

Signed-off-by: jansupol <[email protected]>
  • Loading branch information
jansupol committed May 10, 2021
1 parent 74e2279 commit e129ced
Show file tree
Hide file tree
Showing 50 changed files with 286 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
jdk:
- oraclejdk8
- openjdk11
- openjdk15
- openjdk16

cache:
directories:
Expand Down
22 changes: 22 additions & 0 deletions connectors/jdk-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,28 @@
</plugins>
</build>
</profile>
<profile>
<id>disable_tls1and11</id>
<!-- TLS 1 and TLS 1.1 are disabled for JDK 16 -->
<activation>
<jdk>[16,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<reuseForks>false</reuseForks>
<excludes>
<exclude>**/SslFilterTLS1Test.java</exclude>
<exclude>**/SslFilterTLS11Test.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
10 changes: 9 additions & 1 deletion core-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@
<artifactId>jakarta.inject</artifactId>
</dependency>

<dependency>
<!-- not to warn about missing activation -->
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
<version>${jakarta.activation.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -132,7 +140,7 @@

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

Expand Down
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, 2021 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 @@ -32,14 +32,14 @@
import org.glassfish.jersey.message.MessageBodyWorkers;

import org.hamcrest.core.Is;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
Expand All @@ -53,17 +53,24 @@
*
* @author Marek Potociar
*/
@RunWith(MockitoJUnitRunner.class)
//@RunWith(MockitoJUnitRunner.class)
public class ClientRequestTest {

@Mock
private MessageBodyWorkers workers;
@Mock
private GenericType<?> entityType;

private AutoCloseable mockito;

@Before
public void initMocks() {
MockitoAnnotations.initMocks(this);
mockito = MockitoAnnotations.openMocks(this);
}

@After
public void closeMocks() throws Exception {
mockito.close();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public void testLogInboundEntityMockedStream() throws Exception {

private Answer<?> chunk(int size, char filler) {
return invocation -> {
byte[] buf = invocation.getArgumentAt(0, byte[].class);
int offset = invocation.getArgumentAt(1, Integer.class);
byte[] buf = invocation.getArgument(0, byte[].class);
int offset = invocation.getArgument(1, Integer.class);
Arrays.fill(buf, offset, offset + size, (byte) filler);
return size;
};
Expand Down
1 change: 1 addition & 0 deletions core-common/src/test/resources/surefire.policy
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ grant codebase "file:${project.build.directory}/test-classes/-" {
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
permission java.lang.RuntimePermission "reflectionFactoryAccess";
permission java.lang.RuntimePermission "getProtectionDomain"; // mockito for JDK<16
};

grant codebase "file:${project.build.directory}/classes/-" {
Expand Down
4 changes: 2 additions & 2 deletions examples/cdi-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <!-- this is to avoid Jersey jars to be bundled with the WAR -->
Expand Down
6 changes: 0 additions & 6 deletions examples/helloworld-cdi2-se/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@

<description>Jersey "Hello world" example with CDI 2 SE.</description>

<properties>
<cdi.api.version>2.0</cdi.api.version>
<weld.version>${weld3.version}</weld.version>
</properties>

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
Expand Down Expand Up @@ -91,7 +86,6 @@
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>3.1.1.Final</version>
</dependency>
</dependencies>
</profile>
Expand Down
4 changes: 2 additions & 2 deletions examples/helloworld-spring-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring4</artifactId>
<artifactId>jersey-spring5</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring4.version}</version>
<version>${spring5.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -135,7 +135,7 @@ public List<Option> genericOsgiOptions() {
// javax.annotation must go first!
mavenBundle().groupId("jakarta.annotation").artifactId("jakarta.annotation-api").versionAsInProject(),
// pax exam dependencies
mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
// mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
junitBundles(), // adds junit classes to the OSGi context

// HK2
Expand Down
6 changes: 6 additions & 0 deletions examples/osgi-http-service/functional-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
<artifactId>pax-web-extender-war</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-mvn</artifactId>
<version>1.3.7</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -96,7 +96,7 @@ public List<Option> genericOsgiOptions() {
// javax.annotation has to go first!
mavenBundle().groupId("jakarta.annotation").artifactId("jakarta.annotation-api").versionAsInProject(),

mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
mavenBundle("org.ops4j.pax.url", "pax-url-mvn").versionAsInProject(),
junitBundles(),

// HK2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand All @@ -15,6 +15,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Path;
Expand All @@ -40,8 +41,6 @@

import org.glassfish.grizzly.http.server.HttpServer;

import com.sun.nio.file.SensitivityWatchEventModifier;

/**
* Reload example application.
* <p/>
Expand Down Expand Up @@ -116,7 +115,7 @@ private void registerWatcher(WatchService watcher, Path directory) throws IOExce
new WatchEvent.Kind[]{
StandardWatchEventKinds.ENTRY_MODIFY
},
SensitivityWatchEventModifier.HIGH);
/* SensitivityWatchEventModifier.HIGH */ getWatchEventModifiers());
}

private void reloadApp(final File configFile) {
Expand All @@ -125,6 +124,21 @@ private void reloadApp(final File configFile) {
App.container.reload(rc);
}

/**
* @return sensitivity watch event modifier
*/
private static WatchEvent.Modifier[] getWatchEventModifiers() {
String className = "com.sun.nio.file.SensitivityWatchEventModifier";
try {
Class<?> c = Class.forName(className);
Field f = c.getField("HIGH");
WatchEvent.Modifier modifier = WatchEvent.Modifier.class.cast(f.get(c));
return new WatchEvent.Modifier[] {modifier};
} catch (Exception e) {
return new WatchEvent.Modifier[] {};
}
}

}

private static ResourceConfig createResourceConfig(File configFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ public Object[] getArgs() {

@Override
public void setArgs(final Object[] args) {
this.args = args;
if (args.length == this.args.length) {
// Replace the original arguments with the new ones
System.arraycopy(args, 0, this.args, 0, args.length);
} else {
this.args = args;
}
}

@Override
Expand Down
16 changes: 9 additions & 7 deletions ext/cdi/jersey-cdi1x-validation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@
</dependency>

<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
<version>1.2</version>
<exclusions>
<!-- Remove ancient javax.el that causes problems with Hibernate -->
<exclusion>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021 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 @@ -60,13 +60,13 @@ public CdiInterceptorWrapper(BeanManager beanManager) {

@AroundInvoke
public Object validateMethodInvocation(InvocationContext ctx) throws Exception {
final boolean isJaxRsMethod = extension.jaxRsResourceCache.apply(ctx.getMethod().getDeclaringClass());
final boolean isJaxRsMethod = extension.getJaxRsResourceCache().apply(ctx.getMethod().getDeclaringClass());
return isJaxRsMethod ? ctx.proceed() : interceptor.validateMethodInvocation(ctx);
}

@AroundConstruct
public void validateConstructorInvocation(InvocationContext ctx) throws Exception {
final boolean isJaxRsConstructor = extension.jaxRsResourceCache.apply(ctx.getConstructor().getDeclaringClass());
final boolean isJaxRsConstructor = extension.getJaxRsResourceCache().apply(ctx.getConstructor().getDeclaringClass());
if (!isJaxRsConstructor) {
interceptor.validateConstructorInvocation(ctx);
}
Expand Down
Loading

0 comments on commit e129ced

Please sign in to comment.