[
https://issues.apache.org/jira/browse/SLING-6313?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17352074#comment-17352074
]
Henry Kuijpers commented on SLING-6313:
---------------------------------------
[~akhoury], I'm sorry, i had the intention of posting the script later on, as i
could not access our git box from my mobile phone this morning.
This is the groovy script i made. As i said, it's quick & dirty and definitely
the way of verifying if a config is still present in the ser file can be
improved big time; it currently takes advantage of how the ObjectOutputStream
writes a string into the binary file.
```
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.apache.commons.io.IOUtils;
import java.nio.file.Files;
import java.nio.file.Paths;
// true = only factory configs, false = *all* configurations
def factoryConfigsOnly = true;
// true = only print, false = print + delete
def dryRun = true;
class ConfigurationPidComparator implements Comparator<Configuration> {
@Override
int compare(Configuration first, Configuration second) {
return first.getPid().compareTo(second.getPid());
}
}
def path = "crx-quickstart/launchpad/installer/RegisteredResourceList.ser";
def contents = new String(Files.readAllBytes(Paths.get(path)), "utf-8");
def configurations =
getService(ConfigurationAdmin.class).listConfigurations(factoryConfigsOnly ?
"(service.factoryPid=*)" : null);
Arrays.sort(configurations, new ConfigurationPidComparator());
for (configuration in configurations) {
def pid = configuration.getPid()
if (!contents.contains(pid)) {
print pid + " does not exist!";
if (!dryRun) {
configuration.delete();
println " - Deleted";
} else {
println " - Dry run, not deleting";
}
}
}
```
> Sling installer can duplicate factory configurations if an invalid
> RegisteredResourceList.ser is found
> ------------------------------------------------------------------------------------------------------
>
> Key: SLING-6313
> URL: https://issues.apache.org/jira/browse/SLING-6313
> Project: Sling
> Issue Type: Bug
> Components: Installer
> Reporter: Robert Munteanu
> Assignee: Carsten Ziegeler
> Priority: Major
> Fix For: Installer Core 3.9.0, Installer Configuration Factory
> 1.2.4
>
> Attachments: SLING-6313-0.diff
>
>
> Steps to reproduce, inside `launchpad/builder`
> {noformat}
> mvn clean package
> java -jar target/org.apache.sling.launchpad-9-SNAPSHOT.jar
> # wait for Sling to start up properly, stop it with CTRL-C
> truncate --size=-1 sling/installer/RegisteredResourceList.ser
> java -jar target/org.apache.sling.launchpad-9-SNAPSHOT.jar
> # wait for Sling to start up properly, stop it with CTRL-C
> java -jar target/org.apache.sling.launchpad-9-SNAPSHOT.jar
> {noformat}
> The following exceptions are logged in the last run:
> {noformat}21.11.2016 14:32:26.538 *ERROR* [CM Configuration Updater
> (ManagedServiceFactory Update:
> factoryPid=[org.apache.sling.commons.log.LogManager.factory.config])]
> org.apache.felix.configadmin Service
> [org.apache.felix.cm.ConfigurationAdmin,28,
> [org.osgi.service.cm.ConfigurationAdmin]]
> [org.osgi.service.cm.ManagedServiceFactory, id=19,
> bundle=8/slinginstall:org.apache.sling.commons.log-5.0.1-SNAPSHOT.jar]:
> Updating property org.apache.sling.commons.log.names of configuration
> org.apache.sling.commons.log.LogManager.factory.config.b4cf7982-9af0-40a1-b720-3e83a9f9e7f9
> caused a problem: Category log.request already defined by configuration
> org.apache.sling.commons.log.LogManager.factory.config.b4cf7982-9af0-40a1-b720-3e83a9f9e7f9
> (org.osgi.service.cm.ConfigurationException:
> org.apache.sling.commons.log.names : Category log.request already defined by
> configuration
> org.apache.sling.commons.log.LogManager.factory.config.b4cf7982-9af0-40a1-b720-3e83a9f9e7f9)
> org.osgi.service.cm.ConfigurationException:
> org.apache.sling.commons.log.names : Category log.request already defined by
> configuration
> org.apache.sling.commons.log.LogManager.factory.config.b4cf7982-9af0-40a1-b720-3e83a9f9e7f9
> at
> org.apache.sling.commons.log.logback.internal.config.LoggerManagedServiceFactory.updated(LoggerManagedServiceFactory.java:36)
> at
> org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.updated(ManagedServiceFactoryTracker.java:159)
> at
> org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.provideConfiguration(ManagedServiceFactoryTracker.java:93)
> at
> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.provide(ConfigurationManager.java:1611)
> at
> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.run(ConfigurationManager.java:1554)
> at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)
> at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)
> at java.lang.Thread.run(Thread.java:745)
> Caused by:
> org.apache.sling.commons.log.logback.internal.config.ConfigurationException:
> at
> org.apache.sling.commons.log.logback.internal.LogConfigManager.updateLoggerConfiguration(LogConfigManager.java:533)
> at
> org.apache.sling.commons.log.logback.internal.config.LoggerManagedServiceFactory.updated(LoggerManagedServiceFactory.java:34)
> ... 7 common frames omitted{noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)