You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by jo...@apache.org on 2026/09/26 18:31:31 UTC
(jackrabbit-filevault) branch JCRVLT-852 created (now 90ab5090)
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a change to branch JCRVLT-852
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git
at 90ab5090 JCRVLT-852 log the opening stacktrace for non-closed VaultPackages
This branch includes the following new commits:
new 90ab5090 JCRVLT-852 log the opening stacktrace for non-closed VaultPackages
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-filevault) 01/01: JCRVLT-852 log the opening stacktrace for non-closed VaultPackages
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a commit to branch JCRVLT-852
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git
commit 90ab509069b7d7004d12fbd2f5f54404b8d88a26
Author: Joerg Hoh <jh...@adobe.com>
AuthorDate: Sat Sep 26 20:31:13 2026 +0200
JCRVLT-852 log the opening stacktrace for non-closed VaultPackages
---
.../jackrabbit/vault/fs/io/AbstractArchive.java | 6 +-
.../packaging/impl/OsgiAwarePropertiesUtil.java | 15 ++++
.../impl/OsgiAwarePropertiesUtilTest.java | 80 ++++++++++++++++++++++
3 files changed, 98 insertions(+), 3 deletions(-)
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AbstractArchive.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AbstractArchive.java
index 9849aca2..39e6d5c8 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AbstractArchive.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AbstractArchive.java
@@ -41,11 +41,11 @@ abstract class AbstractArchive implements Archive {
/**
* Determines whether stack traces should be created for each register call of {@link CloseWatcher}.
- * This is false by default.
- * Enable via system or OSGi framework property {@code vault.enableStackTraces}.
+ * This is true by default.
+ * Disable via system or OSGi framework property {@code vault.enableStackTraces}.
*/
protected static final boolean SHOULD_CREATE_STACK_TRACE =
- OsgiAwarePropertiesUtil.getBooleanProperty(PROPERTY_ENABLE_STACK_TRACES);
+ OsgiAwarePropertiesUtil.getBooleanProperty(PROPERTY_ENABLE_STACK_TRACES, true);
@Override
public Entry getEntry(String path) throws IOException {
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/OsgiAwarePropertiesUtil.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/OsgiAwarePropertiesUtil.java
index d7c1f221..4bf5bce4 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/OsgiAwarePropertiesUtil.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/OsgiAwarePropertiesUtil.java
@@ -45,4 +45,19 @@ public class OsgiAwarePropertiesUtil {
public static boolean getBooleanProperty(String key) {
return Boolean.parseBoolean(getProperty(key));
}
+
+ /**
+ * Retrieve a boolean parameter either via bundle context or via system properties. If the value
+ * is not defined, return the provided defaultValue
+ * @param key the name of the property
+ * @param defaultValue the default value to use
+ * @return
+ */
+ public static boolean getBooleanProperty(String key, boolean defaultValue) {
+ String propertyValue = getProperty(key);
+ if (propertyValue == null) {
+ return defaultValue;
+ }
+ return Boolean.parseBoolean(getProperty(key));
+ }
}
diff --git a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/OsgiAwarePropertiesUtilTest.java b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/OsgiAwarePropertiesUtilTest.java
new file mode 100644
index 00000000..e20b9778
--- /dev/null
+++ b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/OsgiAwarePropertiesUtilTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.vault.packaging.impl;
+
+import org.junit.After;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests {@link OsgiAwarePropertiesUtil#getBooleanProperty(String, boolean)}, in particular the
+ * fallback to a caller-supplied default value when the underlying system/bundle-context property
+ * is not set (used e.g. by {@code AbstractArchive#SHOULD_CREATE_STACK_TRACE} to default to
+ * {@code true}).
+ */
+public class OsgiAwarePropertiesUtilTest {
+
+ private static final String KEY = "test.OsgiAwarePropertiesUtilTest.flag";
+
+ @After
+ public void tearDown() {
+ System.clearProperty(KEY);
+ }
+
+ @Test
+ public void unsetPropertyReturnsDefaultValueTrue() {
+ System.clearProperty(KEY);
+ assertTrue(OsgiAwarePropertiesUtil.getBooleanProperty(KEY, true));
+ }
+
+ @Test
+ public void unsetPropertyReturnsDefaultValueFalse() {
+ System.clearProperty(KEY);
+ assertFalse(OsgiAwarePropertiesUtil.getBooleanProperty(KEY, false));
+ }
+
+ @Test
+ public void explicitTruePropertyOverridesDefaultFalse() {
+ System.setProperty(KEY, "true");
+ assertTrue(OsgiAwarePropertiesUtil.getBooleanProperty(KEY, false));
+ }
+
+ @Test
+ public void explicitFalsePropertyOverridesDefaultTrue() {
+ System.setProperty(KEY, "false");
+ assertFalse(OsgiAwarePropertiesUtil.getBooleanProperty(KEY, true));
+ }
+
+ @Test
+ public void unparsablePropertyValueIsTreatedAsFalseRegardlessOfDefault() {
+ // matches java.lang.Boolean#parseBoolean semantics: anything other than "true" (ignoring case) is false
+ System.setProperty(KEY, "not-a-boolean");
+ assertFalse(OsgiAwarePropertiesUtil.getBooleanProperty(KEY, true));
+ }
+
+ @Test
+ public void singleArgOverloadStillDefaultsToFalseWhenUnset() {
+ // regression check: the original getBooleanProperty(String) overload must keep its
+ // existing behavior (defaulting to false) and not be affected by the new overload.
+ System.clearProperty(KEY);
+ assertFalse(OsgiAwarePropertiesUtil.getBooleanProperty(KEY));
+ }
+}