-
Notifications
You must be signed in to change notification settings - Fork 81
Add capability to build and test with JDK up to version 17 (fixes #127) #128
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,19 @@ | ||
| package se.jiderhamn.classloader.leak.prevention.cleanup; | ||
|
|
||
| import org.junit.Assume; | ||
|
|
||
| import se.jiderhamn.classloader.leak.prevention.support.JavaVersion; | ||
|
|
||
| /** | ||
| * Test cases for {@link JavaUtilLoggingLevelCleanUp} | ||
| * @author Mattias Jiderhamn | ||
| */ | ||
| public class JavaUtilLoggingLevelCleanUpTest extends ClassLoaderPreMortemCleanUpTestBase<JavaUtilLoggingLevelCleanUp> { | ||
| @Override | ||
| protected void triggerLeak() throws Exception { | ||
| // Leak does not occur any more with JDK11+ | ||
| Assume.assumeTrue(JavaVersion.IS_JAVA_10_OR_EARLIER); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why isn't
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question - I may have overlooked this one... |
||
|
|
||
| // TODO Log | ||
| // Logger logger = Logger.getLogger(JavaUtilLoggingLevelCleanUpTest.class.getName()); | ||
| // logger.setLevel( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
| import se.jiderhamn.classloader.leak.prevention.ClassLoaderPreMortemCleanUp; | ||
| import se.jiderhamn.classloader.leak.prevention.ReplaceDOMNormalizerSerializerAbortException; | ||
| import se.jiderhamn.classloader.leak.prevention.preinit.ReplaceDOMNormalizerSerializerAbortExceptionInitiatorTest; | ||
| import se.jiderhamn.classloader.leak.prevention.support.JavaVersion; | ||
|
|
||
| import org.junit.Assume; | ||
|
|
||
| /** | ||
| * Test cases for {@link ReplaceDOMNormalizerSerializerAbortException} when used as {@link ClassLoaderPreMortemCleanUp} | ||
|
|
@@ -13,4 +16,12 @@ public class ReplaceDOMNormalizerSerializerAbortExceptionCleanUpTest extends Cla | |
| public void triggerLeak() throws Exception { | ||
| ReplaceDOMNormalizerSerializerAbortExceptionInitiatorTest.triggerLeak(); | ||
| } | ||
|
|
||
| @Override | ||
| public void triggerLeakWithoutCleanup() throws Exception { | ||
| // Leak does not occur any more with JDK8+ | ||
| Assume.assumeTrue(JavaVersion.IS_JAVA_1_6 || JavaVersion.IS_JAVA_1_7); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it have made more sense to make the original Plus,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. |
||
| super.triggerLeakWithoutCleanup(); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,20 @@ | ||
| package se.jiderhamn.classloader.leak.prevention.preinit; | ||
|
|
||
| import org.junit.Assume; | ||
|
|
||
| import se.jiderhamn.classloader.leak.prevention.support.JavaVersion; | ||
|
|
||
| /** | ||
| * Test cases for {@link SunGCInitiator} | ||
| * @author Mattias Jiderhamn | ||
| */ | ||
| public class SunGCInitiatorTest extends PreClassLoaderInitiatorTestBase<SunGCInitiator> { | ||
|
|
||
| @Override | ||
| public void firstShouldLeak() throws Exception { | ||
| // Leak does not occur any more with JDK11+ (and maybe 9 and 10 - not tested) | ||
| Assume.assumeTrue(JavaVersion.IS_JAVA_10_OR_EARLIER); | ||
| super.firstShouldLeak(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| package se.jiderhamn.classloader.leak.prevention.support; | ||
|
|
||
| /** | ||
| * A few helper functions to use as a condition for JDK-dependant unit tests. | ||
| */ | ||
| public class JavaVersion { | ||
|
|
||
| public static final String JAVA_SPECIFICATION_VERSION = System.getProperty("java.specification.version"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 1.6 (also 1.6.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_1_6 = isJavaVersionMatch("1.6"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 1.7 (also 1.7.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_1_7 = isJavaVersionMatch("1.7"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 1.8 (also 1.8.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_1_8 = isJavaVersionMatch("1.8"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 1.8 or earlier (includes 1.8.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_1_8_OR_EARLIER = JavaVersion.IS_JAVA_1_6 || JavaVersion.IS_JAVA_1_7 || JavaVersion.IS_JAVA_1_8; | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 9 (also 9.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_9 = isJavaVersionMatch("9"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 10 (also 10.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_10 = isJavaVersionMatch("10"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 10 or earlier (includes 10.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_10_OR_EARLIER = IS_JAVA_1_8_OR_EARLIER || JavaVersion.IS_JAVA_9 || JavaVersion.IS_JAVA_10; | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 11 (also 11.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_11 = isJavaVersionMatch("11"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 12 (also 12.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_12 = isJavaVersionMatch("12"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 13 (also 13.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_13 = isJavaVersionMatch("13"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 14 (also 14.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_14 = isJavaVersionMatch("14"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 15 (also 15.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_15 = isJavaVersionMatch("15"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 16 (also 16.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_16 = isJavaVersionMatch("16"); | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 16 or earlier (includes 16.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_16_OR_EARLIER = | ||
| IS_JAVA_10_OR_EARLIER | ||
| || JavaVersion.IS_JAVA_11 | ||
| || JavaVersion.IS_JAVA_12 | ||
| || JavaVersion.IS_JAVA_13 | ||
| || JavaVersion.IS_JAVA_14 | ||
| || JavaVersion.IS_JAVA_15 | ||
| || JavaVersion.IS_JAVA_16; | ||
|
|
||
| /** | ||
| * Is {@code true} if this is Java version 17 (also 17.x versions). | ||
| */ | ||
| public static final boolean IS_JAVA_17 = isJavaVersionMatch("17"); | ||
|
|
||
| static boolean isJavaVersionMatch(final String versionPrefix) { | ||
| String version = JAVA_SPECIFICATION_VERSION; | ||
| if (version == null) { | ||
| return false; | ||
| } | ||
| return version.startsWith(versionPrefix); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actualy working for you, @davoustp ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is.
But the
gt-metadataartifact has moved to another repo, and not available in public Maven: http://maven.geo-solutions.it/I struggled quite a bit to find this one, to be honest. :-)