[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369285#comment-16369285 ] Carsten Ziegeler commented on SLING-7496: - Thanks for the updated patches, [~bosschaert] I added a minor tweak to your patch. All tests pass now > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369279#comment-16369279 ] ASF GitHub Bot commented on SLING-7496: --- cziegeler closed pull request #1: SLING-7496 - Fix two failures in ConfigInstallTest URL: https://github.com/apache/sling-org-apache-sling-installer-it/pull/1 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java b/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java index 6a56db0..f27c16f 100644 --- a/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java +++ b/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java @@ -16,10 +16,6 @@ */ package org.apache.sling.installer.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - import java.util.ArrayList; import java.util.Dictionary; import java.util.Hashtable; @@ -48,6 +44,10 @@ import org.osgi.util.tracker.ServiceTracker; import org.osgi.util.tracker.ServiceTrackerCustomizer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + @RunWith(PaxExam.class) public class ConfigInstallTest extends OsgiInstallerTestBase implements ConfigurationListener { @@ -359,6 +359,8 @@ public void testInstallUpdateRemoveConfigFactory() throws Exception { null, cfgData, null, InstallableResource.TYPE_PROPERTIES, 10); installer.updateResources(URL_SCHEME, new InstallableResource[] {rsrc}, null); +waitForResource(URL_SCHEME + ":/configA/" + cfgFactoryPid + "-" + alias, ResourceState.INSTALLED); + // get factory config final Configuration cfg = waitForFactoryConfigValue("After installing", cfgFactoryPid, "foo", "bar"); @@ -392,6 +394,8 @@ public void testInstallUpdateRemoveTemplateConfigFactory() throws Exception { null, cfgData, null, InstallableResource.TYPE_PROPERTIES, 10); installer.updateResources(URL_SCHEME, new InstallableResource[] {rsrc}, null); +waitForResource(URL_SCHEME + ":/configA/" + cfgFactoryPid + "-" + alias, ResourceState.INSTALLED); + // get factory config final Configuration cfg = waitForFactoryConfigValue("After installing", cfgFactoryPid, "foo", "bar"); This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369276#comment-16369276 ] David Bosschaert commented on SLING-7496: - Hi [~cziegele] I guess the test case was incorrect in that is wasn't waiting for the system to reach the initial INSTALLED state for the configurations. I added an extra check to the test cases, and reverted the state to IGNORED where it had this state before. > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369277#comment-16369277 ] ASF GitHub Bot commented on SLING-7496: --- cziegeler closed pull request #2: SLING-7496 Factory config deleted with ConfigAdmin immediately after creation URL: https://github.com/apache/sling-org-apache-sling-installer-factory-configuration/pull/2 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/src/main/java/org/apache/sling/installer/factories/configuration/impl/AbstractConfigTask.java b/src/main/java/org/apache/sling/installer/factories/configuration/impl/AbstractConfigTask.java index c5f4d1d..a1d628a 100644 --- a/src/main/java/org/apache/sling/installer/factories/configuration/impl/AbstractConfigTask.java +++ b/src/main/java/org/apache/sling/installer/factories/configuration/impl/AbstractConfigTask.java @@ -80,7 +80,12 @@ protected String getCompositeAliasPid() { if ( this.aliasPid == null || this.factoryPid == null ) { return null; } -final String alias = factoryPid + "." + this.aliasPid; +final String alias; +if (this.aliasPid.startsWith(this.factoryPid)) { +alias = this.aliasPid; +} else { +alias = this.factoryPid + "." + this.aliasPid; +} final int pos = this.getResource().getEntityId().indexOf(':'); if ( this.getResource().getEntityId().substring(pos + 1).equals(alias) ) { return null; This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369245#comment-16369245 ] David Bosschaert commented on SLING-7496: - Thanks for the feedback [~cziegeler] - I guess in that case the change in https://github.com/apache/sling-org-apache-sling-installer-factory-configuration/pull/1 was incorrect. Maybe the best thing to do would be to back it out for the moment? > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369155#comment-16369155 ] Carsten Ziegeler commented on SLING-7496: - [~bosschaert] I just looked at what ConfigInstallTest#testInstallUpdateRemoveConfigFactory does. As the name says it installs a configuration through the installer, updates the config through CM and then removes the config through CM. Now the desired states are: * config installed through installer. state = INSTALLED * config updated through CM - manual intervention detected, state = IGNORED * config removed through CM - manual intervention detected, state = IGNORED So I think the test is actually correct and the state needs to switch from INSTALLED to IGNORED when a configuration installed through the installer is manually changed > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369105#comment-16369105 ] David Bosschaert commented on SLING-7496: - Hi [~cziegeler] I could be wrong but this is I think the thing that we aimed to fix in this issue in the first place. Originally, because of a mismatch in pids (that had a double factory pid prefixed) when a configuration was created, it was deleted immediately, causing the configuration resource to be assigned the IGNORED state. Since that delete is now not happening any more at the initial state, the resource stays in the INSTALLED state which seems correct... Again, I could be wrong, but this is how I understand it :) > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369099#comment-16369099 ] Carsten Ziegeler commented on SLING-7496: - [~bosschaert] Why does the test case needs that change? > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369093#comment-16369093 ] David Bosschaert commented on SLING-7496: - I created 2 pull requests to address the issue: https://github.com/apache/sling-org-apache-sling-installer-factory-configuration/pull/2 https://github.com/apache/sling-org-apache-sling-installer-it/pull/1 > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369082#comment-16369082 ] ASF GitHub Bot commented on SLING-7496: --- bosschaert opened a new pull request #2: SLING-7496 Factory config deleted with ConfigAdmin immediately after creation URL: https://github.com/apache/sling-org-apache-sling-installer-factory-configuration/pull/2 The PID alias should not have the factory pid prefix twice. This fix is needed to address the ConfigInstallTest.testInstallUpdateRemoveTemplateConfigFactory() failure that was introduced with the previous commit for SLING-7496 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369000#comment-16369000 ] David Bosschaert commented on SLING-7496: - Looking at this issue now... > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16368205#comment-16368205 ] David Bosschaert commented on SLING-7496: - I'll have a look at that test failure early next week. > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16367550#comment-16367550 ] Carsten Ziegeler commented on SLING-7496: - Thanks for your patch, [~bosschaert] I've applied it While it looks ok to me, we now have two failing test cases in the installer-it module: [ERROR] ConfigInstallTest.testInstallUpdateRemoveConfigFactory:370->OsgiInstallerTestBase.waitForResource:607 Resource OsgiInstallerTest:/configA/ConfigInstallTest.1_1518798684784-alias2_1518798684784 not found with state IGNORED : InstallationState[active resources: [], installed resources: [group[[resource[entityId=config:ConfigInstallTest.1_1518798684784.alias2_1518798684784, scheme=OsgiInstallerTest, url=OsgiInstallerTest:/configA/ConfigInstallTest.1_1518798684784-alias2_1518798684784, type=config, error=null, state=INSTALLED, version=null, lastChange=1518798684794, priority=10, digest=9ee95e734039f9382ed7d4efd70b59f0, untransformed resources: []] [ERROR] ConfigInstallTest.testInstallUpdateRemoveTemplateConfigFactory:403->OsgiInstallerTestBase.waitForResource:607 Resource OsgiInstallerTest:/configA/ConfigInstallTest.1_1518798675679-alias2_1518798675679 not found with state IGNORED : InstallationState[active resources: [], installed resources: [group[[resource[entityId=config:ConfigInstallTest.1_1518798675679.alias2_1518798675679, scheme=OsgiInstallerTest, url=OsgiInstallerTest:/configA/ConfigInstallTest.1_1518798675679-alias2_1518798675679, type=config, error=null, state=INSTALLED, version=null, lastChange=1518798675690, priority=10, digest=43cce692adda50cd4af84fedfca210e4, untransformed resources: []] [INFO] It could just be that the test cases need updating, I haven't looked at them yet > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Affects Versions: Installer Configuration Factory 1.1.2 >Reporter: David Bosschaert >Assignee: Carsten Ziegeler >Priority: Major > Fix For: Installer Configuration Factory 1.2.0 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16367545#comment-16367545 ] ASF GitHub Bot commented on SLING-7496: --- cziegeler closed pull request #1: SLING-7496 Factory configurations get deleted on update() URL: https://github.com/apache/sling-org-apache-sling-installer-factory-configuration/pull/1 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pom.xml b/pom.xml index c835e26..3ad5109 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,13 @@ junit junit +test + + +org.mockito +mockito-core +2.15.0 +test diff --git a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java index afa7293..6e0845c 100644 --- a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java +++ b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java @@ -106,7 +106,7 @@ public void configurationEvent(final ConfigurationEvent event) { } else { pid = (event.getPid().startsWith(event.getFactoryPid() + '.') ? event.getPid().substring(event.getFactoryPid().length() + 1) : event.getPid()); -id = event.getFactoryPid() + '.' + event.getPid(); +id = event.getFactoryPid() + '.' + pid; } if ( event.getType() == ConfigurationEvent.CM_DELETED ) { final Coordinator.Operation op = Coordinator.SHARED.get(event.getPid(), event.getFactoryPid(), true); @@ -191,22 +191,7 @@ public void configurationEvent(final ConfigurationEvent event) { final String configPid; int n = pid.indexOf('-'); if (n > 0) { -// quick check if this is an existing configuration -final String fString = pid.substring(0, n); -final String cString = pid.substring(n + 1); -boolean useExtendedPid = false; -try { -if ( ConfigUtil.getConfiguration(this.configAdmin, fString, fString + '.' + cString) != null ) { -useExtendedPid = true; -} -} catch ( final Exception ignore) { -// ignore this -} -if ( useExtendedPid ) { -configPid = fString + '.' + cString; -} else { -configPid = pid.substring(n + 1); -} +configPid = pid.substring(n + 1); factoryPid = pid.substring(0, n); } else { factoryPid = null; diff --git a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java index 981d590..a9eba9f 100644 --- a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java +++ b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java @@ -193,6 +193,12 @@ private static Configuration getOrCreateConfiguration(final ConfigurationAdmin c + ")(" + Constants.SERVICE_PID + "=" + encode(configPid) + "))"); } +if (configs == null || configs.length == 0) { +configs = ca.listConfigurations("(&(" ++ ConfigurationAdmin.SERVICE_FACTORYPID + "=" + encode(factoryPid) ++ ")(" + Constants.SERVICE_PID + "=" + encode(factoryPid + "." + configPid) ++ "))"); +} if (configs == null || configs.length == 0) { // check for old style with alias pid configs = ca.listConfigurations( diff --git a/src/test/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtilTest.java b/src/test/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtilTest.java index 7ef7ca9..2b0c9a6 100644 --- a/src/test/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtilTest.java +++ b/src/test/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtilTest.java @@ -18,14 +18,19 @@ */ package org.apache.sling.installer.factories.configuration.impl; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.util.Dictionary; import java.util.Enumeration; import java.util.Hashtable; import org.junit.Test; +import org.moc
[jira] [Commented] (SLING-7496) Factory config deleted with ConfigAdmin immediately after creation
[ https://issues.apache.org/jira/browse/SLING-7496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16367544#comment-16367544 ] ASF GitHub Bot commented on SLING-7496: --- bosschaert opened a new pull request #1: SLING-7496 Factory configurations get deleted on update() URL: https://github.com/apache/sling-org-apache-sling-installer-factory-configuration/pull/1 The factory prefix was prepended twice which caused the installer to think that the original configuration being updated was gone, which triggered a callback to Configuration.delete(); This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Factory config deleted with ConfigAdmin immediately after creation > -- > > Key: SLING-7496 > URL: https://issues.apache.org/jira/browse/SLING-7496 > Project: Sling > Issue Type: Bug > Components: Installer >Reporter: David Bosschaert >Priority: Major > Fix For: Installer Configuration Factory 1.1.2 > > > In some cases when a factory configuration is created using the OSGi > ConfigAdmin API, the configuration gets a call to {{delete()}} immediately > when {{update()}} on the configuration is called. > > The issue comes down to the fact that the factory prefix is prepended twice > to the configuration at some point in the installer, which is then assigned > to the resource {{entityId}}. This mismatch causes the initial configuration > to receive a delete callback as the system thinks it's no longer there. -- This message was sent by Atlassian JIRA (v7.6.3#76005)