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-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 2243498  SLING-7505 set error state also for resources which are not 
on the first position
2243498 is described below

commit 22434982726f0198402be4ca682dae5b5a268586
Author: Konrad Windszus <[email protected]>
AuthorDate: Sun Feb 18 18:40:03 2018 +0100

    SLING-7505 set error state also for resources which are not on the first
    position
---
 .../org/apache/sling/installer/core/impl/EntityResourceList.java   | 7 ++++++-
 .../org/apache/sling/installer/core/impl/OsgiInstallerImpl.java    | 5 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java 
b/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
index ed11429..f533e00 100644
--- a/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
+++ b/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
@@ -285,7 +285,7 @@ public class EntityResourceList implements Serializable, 
TaskResourceGroup {
                         while ( i.hasNext() ) {
                             final TaskResource rsrc = i.next();
                             if ( rsrc.getState() == ResourceState.INSTALLED ) {
-                                
((RegisteredResourceImpl)rsrc).setState(ResourceState.INSTALL, null);
+                                
((RegisteredResourceImpl)rsrc).setState(ResourceState.INSTALL, "Another 
resource with the same entity id but a higher version or priority or digest 
found (in that order, the latter only in case the version is a SNAPSHOT)!");
                             }
                         }
                     }
@@ -413,7 +413,12 @@ public class EntityResourceList implements Serializable, 
TaskResourceGroup {
             }
             if ( add ) {
                 resources.add(r);
+                // make sure that in case the newly added resource is not the 
first one the state is saying why it is in mode install
                 Collections.sort(this.resources);
+                if (r != resources.get(0)) {
+                    // don't change actual state but indicate why resource is 
not considered for subsequent runs (not on first position)
+                    r.setState(ResourceState.INSTALL, "Another resource with 
the same entity id but a higher version or priority or digest found (in that 
order, the latter only in case the version is a SNAPSHOT)!");
+                }
             }
         }
     }
diff --git 
a/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java 
b/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
index 86a408c..be27bba 100644
--- a/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
+++ b/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
@@ -675,8 +675,9 @@ implements OsgiInstaller, ResourceChangeListener, 
RetryHandler, InfoProvider, Ru
                 try {
                     result = factory.createTask(rrg);
                 } catch ( final Exception fatal ) {
-                    logger.error("An exception occured while creating a task 
for " + rrg.getActiveResource()+ ". Resource will be ignored.", fatal);
-                    result = new ChangeStateTask(rrg, ResourceState.IGNORED);
+                    String message = MessageFormat.format("An exception 
occured while creating a task for {0}. Resource will be ignored: {1}", 
rrg.getActiveResource(), fatal.getMessage());
+                    logger.error(message, fatal);
+                    result = new ChangeStateTask(rrg, ResourceState.IGNORED, 
message);
                 }
                 if ( result != null ) {
                     break;

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to