You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2021/01/08 10:57:17 UTC
[sling-org-apache-sling-installer-factory-configuration] branch
master updated: SLING-10043 - Naming OSGi configs with dashes breaks the
OSGi installer
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-factory-configuration.git
The following commit(s) were added to refs/heads/master by this push:
new e004bf7 SLING-10043 - Naming OSGi configs with dashes breaks the OSGi installer
e004bf7 is described below
commit e004bf712d9c05fed4021dd0e45dae21eb286c40
Author: akankshajain18 <cs...@gmail.com>
AuthorDate: Thu Jan 7 17:45:47 2021 +0530
SLING-10043 - Naming OSGi configs with dashes breaks the OSGi installer
rombert: fixed indentation
Closes #6
---
.../factories/configuration/impl/ConfigUpdateHandler.java | 12 +++++++-----
.../configuration/impl/ConfigUpdateHandlerTest.java | 7 +++++++
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUpdateHandler.java b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUpdateHandler.java
index ae0dd75..e4d7b12 100644
--- a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUpdateHandler.java
+++ b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUpdateHandler.java
@@ -121,12 +121,14 @@ public class ConfigUpdateHandler implements ResourceUpdater {
//format assumption ::: "factory_pid.factory_pid.pid"
// split pid with lastIndexOf('.') then remove the duplicate factory_pid part from the remaining string using the middle dot split index
final int lastDotIndex = oldId.lastIndexOf('.');
- final String factoryIdString = oldId.substring(0, lastDotIndex + 1); // keep it +1 to have last dot intact
- // so that we always have even dots in
- // the string
- factoryPid = oldId.substring(0, getMiddleDotSplitIndex(factoryIdString));
+ if(lastDotIndex < 0) { //when oldId does not contain any dot
+ factoryPid = oldId;
+ } else {
+ final String factoryIdString = oldId.substring(0, lastDotIndex + 1); // keep it +1 to have last dot intact
+ // so that we always have even dots in the string
+ factoryPid = oldId.substring(0, getMiddleDotSplitIndex(factoryIdString));
+ }
pid = oldId.substring(lastDotIndex+1);
-
}
return new String[] { factoryPid, pid };
diff --git a/src/test/java/org/apache/sling/installer/factories/configuration/impl/ConfigUpdateHandlerTest.java b/src/test/java/org/apache/sling/installer/factories/configuration/impl/ConfigUpdateHandlerTest.java
index 894a290..204d94e 100644
--- a/src/test/java/org/apache/sling/installer/factories/configuration/impl/ConfigUpdateHandlerTest.java
+++ b/src/test/java/org/apache/sling/installer/factories/configuration/impl/ConfigUpdateHandlerTest.java
@@ -52,6 +52,13 @@ public class ConfigUpdateHandlerTest {
null,
"org.apache.sling.commons.log.LogManager.factory.config.org.apache.sling.commons.log.LogManager.factory.config.3a514ecf-2e1d-4903-bf88-d878360e8ff1",
"org.apache.sling.commons.log.LogManager.factory.config", "3a514ecf-2e1d-4903-bf88-d878360e8ff1");
+
+ // case where alias is null and factoryPid and Pid would be inferred from oldId itself
+ checkFactoryPid(
+ null,
+ "org-test-form-servlet",
+ "org-test-form-servlet", "org-test-form-servlet");
+
}
@Test