aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2021-07-07 10:04:30 +0000
committerDominik Stadler <centic@apache.org>2021-07-07 10:04:30 +0000
commitb0eca0a9cad66e3eedca8fed37102cff8c6af8cc (patch)
tree18196cda64651f4cb25b18660b488da91a989305 /poi
parent6fabb98ea87efced52b1586e8ea69a4d33be433f (diff)
downloadpoi-b0eca0a9cad66e3eedca8fed37102cff8c6af8cc.tar.gz
poi-b0eca0a9cad66e3eedca8fed37102cff8c6af8cc.zip
Do not fail on invalid access due to JPMS restrictions
Also getImplementationVersion() returns null sometimes, so revert to system-properties git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891349 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/test/java/org/apache/poi/util/ConditionalExecution.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java b/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java
index 9158d20577..f77d556749 100644
--- a/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java
+++ b/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java
@@ -71,19 +71,27 @@ public class ConditionalExecution {
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
String version = Runtime.class.getPackage().getImplementationVersion();
- return findAnnotation(context.getElement(), DisabledOnJreEx.class).filter(annotation -> !isEnabled(annotation))
- .map(annotation -> disabled("PatchLevel skipped", "JRE version " + version + " skipped"))
- .orElseGet(() -> enabled("PatchLevel not matched"));
+ try {
+ return findAnnotation(context.getElement(), DisabledOnJreEx.class).filter(annotation -> !isEnabled(annotation))
+ .map(annotation -> disabled("PatchLevel skipped", "JRE version " + version + " skipped"))
+ .orElseGet(() -> enabled("PatchLevel not matched"));
+ } catch (IllegalAccessError e) {
+ // cannot access org.junit.platform.commons.util.AnnotationUtils when run in JPMS
+ // for now let's ignore this check and report "enabled"
+ return ConditionEvaluationResult.enabled("Cannot check annotation: " + e);
+ }
}
-
boolean isEnabled(DisabledOnJreEx annotation) {
String[] versions = annotation.value();
Preconditions.condition(versions.length > 0, "You must declare at least one JRE version in @DisabledOnJreEx");
- String version = Runtime.class.getPackage().getImplementationVersion();
+ String version1 = Runtime.class.getPackage().getImplementationVersion();
+ if (version1 == null) {
+ // revert to system-property if no implementation version is available
+ version1 = System.getProperty("java.version");
+ }
+ String version = version1;
return Arrays.stream(versions).noneMatch(p -> Pattern.matches(p, version));
}
-
}
-
}