You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2021/07/07 10:04:30 UTC

svn commit: r1891349 - /poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java

Author: centic
Date: Wed Jul  7 10:04:30 2021
New Revision: 1891349

URL: http://svn.apache.org/viewvc?rev=1891349&view=rev
Log:
Do not fail on invalid access due to JPMS restrictions

Also getImplementationVersion() returns null sometimes, so revert to system-properties

Modified:
    poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java

Modified: poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java?rev=1891349&r1=1891348&r2=1891349&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java Wed Jul  7 10:04:30 2021
@@ -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));
         }
-
     }
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org