You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by re...@apache.org on 2025/06/18 13:28:03 UTC
(sling-org-apache-sling-resourceresolver) branch SLING-12832 created (now 71e9e34b)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a change to branch SLING-12832
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
at 71e9e34b SLING-12832: alias refactoring - move alias init into Runnable
This branch includes the following new commits:
new 71e9e34b SLING-12832: alias refactoring - move alias init into Runnable
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.
(sling-org-apache-sling-resourceresolver) 01/01: SLING-12832: alias refactoring - move alias init into Runnable
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch SLING-12832
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit 71e9e34b5a03b4325d2fe787ed0f4afa993a7e91
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Wed Jun 18 14:27:44 2025 +0100
SLING-12832: alias refactoring - move alias init into Runnable
---
.../impl/mapping/AliasHandler.java | 69 ++++++++++++++--------
1 file changed, 44 insertions(+), 25 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/AliasHandler.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/AliasHandler.java
index cf41d0ac..b91728f6 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/AliasHandler.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/AliasHandler.java
@@ -126,33 +126,10 @@ class AliasHandler {
return;
}
- List<String> conflictingAliases = new ArrayList<>();
- List<String> invalidAliases = new ArrayList<>();
-
// optimization made in SLING-2521
if (this.factory.isOptimizeAliasResolutionEnabled()) {
- try {
- this.aliasMapsMap = this.loadAliases(conflictingAliases, invalidAliases);
-
- // warn if there are more than a few defunct aliases
- if (conflictingAliases.size() >= MAX_REPORT_DEFUNCT_ALIASES) {
- log.warn(
- "There are {} conflicting aliases; excerpt: {}",
- conflictingAliases.size(),
- conflictingAliases);
- } else if (!conflictingAliases.isEmpty()) {
- log.warn("There are {} conflicting aliases: {}", conflictingAliases.size(), conflictingAliases);
- }
-
- if (invalidAliases.size() >= MAX_REPORT_DEFUNCT_ALIASES) {
- log.warn("There are {} invalid aliases; excerpt: {}", invalidAliases.size(), invalidAliases);
- } else if (!invalidAliases.isEmpty()) {
- log.warn("There are {} invalid aliases: {}", invalidAliases.size(), invalidAliases);
- }
- } catch (Exception e) {
- this.aliasMapsMap = UNITIALIZED_MAP;
- logDisableAliasOptimization(e);
- }
+ AliasInitializer ai = new AliasInitializer();
+ ai.run();
}
doUpdateConfiguration.run();
@@ -162,6 +139,48 @@ class AliasHandler {
}
}
+ private class AliasInitializer implements Runnable {
+
+ public AliasInitializer() {}
+
+ @Override
+ public void run() {
+ try {
+ execute();
+ } catch (Exception ex) {
+ log.error("alias initializer thread terminated with an exception", ex);
+ }
+ }
+
+ private void execute() {
+ try {
+ List<String> conflictingAliases = new ArrayList<>();
+ List<String> invalidAliases = new ArrayList<>();
+
+ aliasMapsMap = loadAliases(conflictingAliases, invalidAliases);
+
+ // warn if there are more than a few defunct aliases
+ if (conflictingAliases.size() >= MAX_REPORT_DEFUNCT_ALIASES) {
+ log.warn(
+ "There are {} conflicting aliases; excerpt: {}",
+ conflictingAliases.size(),
+ conflictingAliases);
+ } else if (!conflictingAliases.isEmpty()) {
+ log.warn("There are {} conflicting aliases: {}", conflictingAliases.size(), conflictingAliases);
+ }
+
+ if (invalidAliases.size() >= MAX_REPORT_DEFUNCT_ALIASES) {
+ log.warn("There are {} invalid aliases; excerpt: {}", invalidAliases.size(), invalidAliases);
+ } else if (!invalidAliases.isEmpty()) {
+ log.warn("There are {} invalid aliases: {}", invalidAliases.size(), invalidAliases);
+ }
+ } catch (Exception e) {
+ aliasMapsMap = UNITIALIZED_MAP;
+ logDisableAliasOptimization(e);
+ }
+ }
+ }
+
boolean usesCache() {
return this.aliasMapsMap != UNITIALIZED_MAP;
}