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

3x.merge #4793

Merged
merged 4 commits into from
May 13, 2021
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
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 @@ -87,6 +87,28 @@
<surefire.security.argline>-Djdk.tls.server.protocols=TLSv1.2</surefire.security.argline>
</properties>
</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-api</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, 2020 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 @@ -218,7 +218,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/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() {
// jakarta.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 @@ -100,7 +100,7 @@ public List<Option> genericOsgiOptions() {
// jakarta.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 @@ -82,8 +82,8 @@ public Object[] getArgs() {
@Override
public void setArgs(final Object[] args) {
if (args.length == this.args.length) {
// Replace the original arguments with the new ones
System.arraycopy(args, 0, this.args, 0, args.length);
// Replace the original arguments with the new ones
System.arraycopy(args, 0, this.args, 0, args.length);
} else {
this.args = args;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020 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 @@ -178,10 +178,6 @@ public void destroy(ValidationInterceptor instance,
}

/* package */ Cache<Class<?>, Boolean> getJaxRsResourceCache() {
/* CDI injection hack */
if (jaxRsResourceCache == null) {
jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null);
}
return jaxRsResourceCache;
}
}
2 changes: 1 addition & 1 deletion ext/microprofile/mp-rest-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<!-- <version>2.0</version>-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 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 All @@ -16,8 +16,15 @@

package org.glassfish.jersey.microprofile.restclient;

import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.internal.util.collection.LazyUnsafeValue;
import org.glassfish.jersey.internal.util.collection.UnsafeValue;
import org.glassfish.jersey.internal.util.collection.Values;

import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.security.AccessController;
import java.security.PrivilegedAction;
Expand Down Expand Up @@ -47,15 +54,31 @@ static <T> T createProxyInstance(Class<T> restClientClass) {
Thread.currentThread().getContextClassLoader(),
new Class[] {restClientClass},
(proxy, m, args) -> {
Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class
.getDeclaredConstructor(Class.class);
constructor.setAccessible(true);
return constructor.newInstance(restClientClass)
final MethodHandles.Lookup lookup = JdkVersion.getJdkVersion().getMajor() > 1
? privateLookupJDK11(restClientClass) : privateLookupJDK8(restClientClass);
return lookup
.in(restClientClass)
.unreflectSpecial(m, restClientClass)
.bindTo(proxy)
.invokeWithArguments(args);
}));
}

private static LazyUnsafeValue<Method, Exception> privateLookup = Values.lazy((UnsafeValue<Method, Exception>)
() -> MethodHandles.class.getMethod("privateLookupIn", Class.class, MethodHandles.Lookup.class)
);

private static MethodHandles.Lookup privateLookupJDK11(Class<?> restClientClass)
throws Exception {
return (MethodHandles.Lookup) privateLookup.get().invoke(null, restClientClass, MethodHandles.lookup());
}

private static MethodHandles.Lookup privateLookupJDK8(Class<?> restClientClass)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
final Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class
.getDeclaredConstructor(Class.class);
constructor.setAccessible(true); //JEP 396 issue
return constructor.newInstance(restClientClass);
}

}
18 changes: 18 additions & 0 deletions ext/spring4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,23 @@
</plugins>
</build>
</profile>
<profile>
<id>ignore.on.jdk16</id>
<!-- Spring 4 does not support JDK 16 at the moment, and it is superseded by Spring 5.2-5.3 -->
<activation>
<jdk>[16,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading