This is an automated email from the ASF dual-hosted git repository.

kwin 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 2c09d98  SLING-8281 improve exception handling (#3)
2c09d98 is described below

commit 2c09d98509ac1baef935b82eac68dffb0c4354d2
Author: Konrad Windszus <[email protected]>
AuthorDate: Wed Feb 20 12:16:51 2019 +0100

    SLING-8281 improve exception handling (#3)
    
    distinguish between recoverable and non-recoverable exceptions and set
    the finish state accordingly
---
 .../factories/configuration/impl/ConfigInstallTask.java       |  9 ++++++++-
 .../installer/factories/configuration/impl/ConfigUtil.java    | 11 +++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigInstallTask.java
 
b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigInstallTask.java
index c880f0f..7285e86 100644
--- 
a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigInstallTask.java
+++ 
b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigInstallTask.java
@@ -18,6 +18,9 @@
  */
 package org.apache.sling.installer.factories.configuration.impl;
 
+import java.io.IOException;
+import java.text.MessageFormat;
+
 import org.apache.sling.installer.api.tasks.InstallationContext;
 import org.apache.sling.installer.api.tasks.ResourceState;
 import org.apache.sling.installer.api.tasks.TaskResourceGroup;
@@ -83,8 +86,12 @@ public class ConfigInstallTask extends AbstractConfigTask {
                 // in any case set the state to "INSTALLED"
                 // (it doesn't matter if the configuration hasn't been updated 
as it has been in the correct state already)
                 this.setFinishedState(ResourceState.INSTALLED);
+            } catch (IOException|IllegalStateException e) {
+                this.getLogger().debug("Temporary exception during 
installation of config " + this.getResource() + " : " + e.getMessage() + ". 
Retrying later.", e);
             } catch (Exception e) {
-                this.getLogger().debug("Exception during installation of 
config " + this.getResource() + " : " + e.getMessage() + ". Retrying later.", 
e);
+                String message = MessageFormat.format("Exception during 
installation of config {0} : {1}", this.getResource(), e.getMessage());
+                this.getLogger().error(message, e);
+                this.setFinishedState(ResourceState.IGNORED, null, message);
             }
         }
     }
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 1c49512..c5dc328 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
@@ -166,6 +166,17 @@ abstract class ConfigUtil {
         return getOrCreateConfiguration(ca, factoryPid, configPidOrName, 
location, true);
     }
 
+    /**
+     * 
+     * @param ca
+     * @param factoryPid
+     * @param configPidOrName
+     * @param location
+     * @param createIfNeeded
+     * @return
+     * @throws IOException - if access to persistent storage fails
+     * @throws InvalidSyntaxException
+     */
     private static Configuration getOrCreateConfiguration(final 
ConfigurationAdmin ca,
             final String factoryPid,
             final String configPidOrName,

Reply via email to