From a2df13d1b3a78d5d05ea19fc9eb601df5138aca2 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Wed, 23 Jan 2019 20:03:22 +0100 Subject: [PATCH] GH-251 Fixed JDK 11 issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added JDK 11 hook in FunctionCreatorConfiguration for javax.annotation to be loaded from current CL - Ensured the file: protocol resources end with the forward slash. See UrlClassPath.getLoader of JDK 11 for more details as to why - Re-enabled conditional tests by removing Java 8 assumptions - Part of the issue was also, the invoker plugin which was only generating ‘it/..’ directory every other time due to exists condition, thus resulting in some test failures every other time (missing directory) Resolves #251 --- spring-cloud-function-deployer/pom.xml | 4 +--- .../function/deployer/ApplicationBootstrap.java | 12 +++++------- .../cloud/function/deployer/ApplicationRunner.java | 6 +++--- .../deployer/FunctionCreatorConfiguration.java | 2 +- .../SpringFunctionFluxConfigurationTests.java | 6 +----- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/spring-cloud-function-deployer/pom.xml b/spring-cloud-function-deployer/pom.xml index 048cdc641..c538c2891 100644 --- a/spring-cloud-function-deployer/pom.xml +++ b/spring-cloud-function-deployer/pom.xml @@ -17,8 +17,7 @@ 1.0.10.RELEASE - 1.3.2.RELEASE - true + 2.0.0.RELEASE @@ -81,7 +80,6 @@ 3.0.1 ${project.build.directory}/local-repo - ${skip.invoke} diff --git a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/ApplicationBootstrap.java b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/ApplicationBootstrap.java index 260238192..1affd8359 100644 --- a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/ApplicationBootstrap.java +++ b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/ApplicationBootstrap.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.springframework.util.StringUtils; * reactor-core (if present). It can then share the reactor dependency with other class * loaders that the app itself creates, without any other classes being shared, other than * the core JDK. - * + * * @author Mark Fisher * @author Dave Syer */ @@ -51,7 +51,7 @@ public class ApplicationBootstrap { /** * Run the provided main class as a Spring Boot application with the provided command * line arguments. - * + * * @param mainClass the main class * @param args the command line arguments */ @@ -141,6 +141,7 @@ public class ApplicationBootstrap { return new URLClassLoader(child.toArray(new URL[0]), base); } + private URL[] findClassPath(Class mainClass) { ClassLoader base = mainClass.getClassLoader(); if (!(base instanceof URLClassLoader)) { @@ -152,10 +153,7 @@ public class ApplicationBootstrap { result.add(mainClass.getProtectionDomain().getCodeSource().getLocation()); for (URL url : list) { String path = url.toString(); - path = path.substring(0, path.length() - "/META-INF".length()); - if (path.endsWith("!")) { - path = path + "/"; - } + path = path.substring(0, path.length() - "/META-INF".length()) + "/"; result.add(new URL(path)); } return result.toArray(new URL[result.size()]); diff --git a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/ApplicationRunner.java b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/ApplicationRunner.java index cb1f4bdf8..3e8f3c045 100644 --- a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/ApplicationRunner.java +++ b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/ApplicationRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import org.springframework.util.ClassUtils; * Initialize an instance of this class with the class loader to be used and the name of * the main class (usually a @SpringBootApplication), and then * {@link #run(String...)} it, cleaning up with a call to {@link #close()}. - * + * * @author Dave Syer */ public class ApplicationRunner { @@ -148,7 +148,7 @@ public class ApplicationRunner { /** * List the bean names in the application context for a given type (by its fully qualified name). - * + * * @param type the name of the type (Class) * @return the bean names of that type */ diff --git a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionCreatorConfiguration.java b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionCreatorConfiguration.java index 4dfd16b24..6c30a9d05 100644 --- a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionCreatorConfiguration.java +++ b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionCreatorConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-function-deployer/src/test/java/org/springframework/cloud/function/deployer/SpringFunctionFluxConfigurationTests.java b/spring-cloud-function-deployer/src/test/java/org/springframework/cloud/function/deployer/SpringFunctionFluxConfigurationTests.java index 730fe05da..6ff50346c 100644 --- a/spring-cloud-function-deployer/src/test/java/org/springframework/cloud/function/deployer/SpringFunctionFluxConfigurationTests.java +++ b/spring-cloud-function-deployer/src/test/java/org/springframework/cloud/function/deployer/SpringFunctionFluxConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,11 @@ import java.lang.reflect.InvocationTargetException; import java.util.function.Function; import org.junit.After; -import org.junit.Assume; import org.junit.Before; import org.junit.Test; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.system.JavaVersion; import org.springframework.cloud.function.context.FunctionCatalog; import org.springframework.cloud.function.context.catalog.FunctionInspector; @@ -46,8 +44,6 @@ public class SpringFunctionFluxConfigurationTests { @Before public void run() { - Assume.assumeTrue("Java > 8", - JavaVersion.getJavaVersion().isOlderThan(JavaVersion.NINE)); if (bootstrap == null) { bootstrap = new ApplicationBootstrap(); bootstrap.run(SpringFunctionFluxConfigurationTests.class,