You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2021/01/27 10:21:54 UTC
[sling-org-apache-sling-jcr-packageinit] 24/25: SLING-10089 -
incorporating suggestions of review (cleaning up pom & adding suppressed
exceptions to IllegalStateException over logging individually)
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-jcr-packageinit.git
commit 2c3933c053ae4a3c8d4edc212f97a8ee5cca5b1c
Author: Dominik Suess <su...@adobe.com>
AuthorDate: Wed Jan 27 11:18:06 2021 +0100
SLING-10089 - incorporating suggestions of review (cleaning up pom & adding suppressed exceptions to IllegalStateException over logging individually)
---
pom.xml | 12 ------------
.../jcr/packageinit/impl/ExecutionPlanRepoInitializer.java | 5 +++--
.../jcr/packageinit/ExecutionPlanRepoInitializerTest.java | 7 ++++---
3 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9ff07d3..ea927a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,18 +39,6 @@
<url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-jcr-packageinit.git</url>
<tag>HEAD</tag>
</scm>
- <build>
- <plugins>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-baseline-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
<dependencies>
<dependency>
diff --git a/src/main/java/org/apache/sling/jcr/packageinit/impl/ExecutionPlanRepoInitializer.java b/src/main/java/org/apache/sling/jcr/packageinit/impl/ExecutionPlanRepoInitializer.java
index 1018631..4d88d8a 100644
--- a/src/main/java/org/apache/sling/jcr/packageinit/impl/ExecutionPlanRepoInitializer.java
+++ b/src/main/java/org/apache/sling/jcr/packageinit/impl/ExecutionPlanRepoInitializer.java
@@ -165,12 +165,13 @@ public class ExecutionPlanRepoInitializer implements SlingRepositoryInitializer
ExecutionPlan xplan = builder.execute();
if (xplan.getTasks().size() > 0) {
if (xplan.hasErrors()) {
+ IllegalStateException ex = new IllegalStateException("Excecutionplan execution contained errors - cannot complete repository initialization.");
for (PackageTask task : xplan.getTasks()) {
if (PackageTask.State.ERROR.equals(task.getState())){
- logger.error("Error during installation of {}: {}", task.getPackageId().toString(), task.getError().toString());
+ ex.addSuppressed(task.getError());
}
}
- throw new IllegalStateException("Excecutionplan execution contained errors - cannot complete repository initialization.");
+ throw ex;
}
logger.info("executionplan executed with {} entries", xplan.getTasks().size());
} else {
diff --git a/src/test/java/org/apache/sling/jcr/packageinit/ExecutionPlanRepoInitializerTest.java b/src/test/java/org/apache/sling/jcr/packageinit/ExecutionPlanRepoInitializerTest.java
index acdb656..123a3cd 100644
--- a/src/test/java/org/apache/sling/jcr/packageinit/ExecutionPlanRepoInitializerTest.java
+++ b/src/test/java/org/apache/sling/jcr/packageinit/ExecutionPlanRepoInitializerTest.java
@@ -207,7 +207,8 @@ public class ExecutionPlanRepoInitializerTest {
PackageTask pt = mock(PackageTask.class);
when(pt.getPackageId()).thenReturn(PackageId.fromString("test:test:1.0"));
when(pt.getState()).thenReturn(State.ERROR);
- when(pt.getError()).thenReturn(new Throwable("expectedException"));
+ Throwable testEx = new Throwable("expectedException");
+ when(pt.getError()).thenReturn(testEx);
ptl.add(pt);
when(xplan.getTasks()).thenReturn(ptl);
when(xplan.hasErrors()).thenReturn(true);
@@ -218,13 +219,13 @@ public class ExecutionPlanRepoInitializerTest {
cdl.await(20500, TimeUnit.MILLISECONDS);
verify(builder, times(1)).load(captor.capture());
assertTrue("Expected IllegalStateException.",foundExceptions.get(0) instanceof IllegalStateException);
-
+ assertEquals(testEx.getMessage(), foundExceptions.get(0).getSuppressed()[0].getMessage());
+
List<ILoggingEvent> logsList = listAppender.list;
assertEquals("Waiting for PackageRegistry.", logsList.get(0)
.getMessage());
assertEquals("PackageRegistry found - starting execution of executionplan", logsList.get(1)
.getMessage());
- assertEquals("Error during installation of test:test:1.0: java.lang.Throwable: expectedException", logsList.get(2).getFormattedMessage());
}