diff --git a/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java b/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java
index 3d432a61..700586ae 100644
--- a/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java
+++ b/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java
@@ -79,9 +79,16 @@ public final class GlobResolver {
* a complex glob pattern can starve CPU/memory on a host.
*
*
Glob limit value taken from https://github.com/openbsd/src/commit/46df4fe576b7
+ * href="https://github.com/openbsd/src/commit/46df4fe576b7">https://github.com/openbsd/src/commit/46df4fe576b7.
+ *
+ *
If test mode is enabled, a smaller value is used. This greatly speeds up the test that
+ * verifies enforcement of the limit (invalidGlobImport6.pkl).
+ *
+ *
Not a static field to prevent compile-time evaluation by native-image.
*/
- private static final int MAX_LIST_ELEMENTS = 16384;
+ private static int maxListElements() {
+ return IoUtils.isTestMode() ? 512 : 16384;
+ }
private static final Map patterns =
Collections.synchronizedMap(new WeakHashMap<>());
@@ -338,7 +345,7 @@ public final class GlobResolver {
List result)
throws IOException, SecurityManagerException, InvalidGlobPatternException {
- if (listElementCallCount.getAndIncrement() > MAX_LIST_ELEMENTS) {
+ if (listElementCallCount.getAndIncrement() > maxListElements()) {
throw new InvalidGlobPatternException(ErrorMessages.create("invalidGlobTooComplex"));
}
var elements = reader.listElements(securityManager, baseUri);
diff --git a/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java b/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java
index 96ee80b7..a0d790bb 100644
--- a/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java
+++ b/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java
@@ -531,7 +531,7 @@ public final class IoUtils {
return ServiceLoader.load(serviceClass, IoUtils.class.getClassLoader());
}
- // not a static property to avoid compile-time evaluation by native-image
+ // not a static field to avoid compile-time evaluation by native-image
public static boolean isTestMode() {
return Boolean.getBoolean("org.pkl.testMode");
}