You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:50:10 UTC
[sling-org-apache-sling-jcr-repoinit] 25/29: Fix NPE in processing
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.repoinit-1.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git
commit c63140f802e512d7f3379568f8acddbede414005
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Nov 9 08:18:44 2016 +0000
Fix NPE in processing
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/repoinit@1768865 13f79535-47bb-0310-9956-ffa450edef68
---
.../jcr/repoinit/impl/RepositoryInitializer.java | 26 ++++++++++++----------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
index f4abbe3..44f2e94 100644
--- a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
+++ b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
@@ -84,19 +84,21 @@ public class RepositoryInitializer implements SlingRepositoryInitializer {
@Override
public void processRepository(SlingRepository repo) throws Exception {
- // loginAdministrative is ok here, definitely an admin operation
- final Session s = repo.loginAdministrative(null);
- try {
- final RepoinitTextProvider p = new RepoinitTextProvider();
- for(String reference : config.references()) {
- final String repoinitText = p.getRepoinitText(reference);
- final List<Operation> ops = parser.parse(new StringReader(repoinitText));
- log.info("Executing {} repoinit operations", ops.size());
- processor.apply(s, ops);
- s.save();
+ if ( config.references() != null && config.references().length > 0 ) {
+ // loginAdministrative is ok here, definitely an admin operation
+ final Session s = repo.loginAdministrative(null);
+ try {
+ final RepoinitTextProvider p = new RepoinitTextProvider();
+ for(String reference : config.references()) {
+ final String repoinitText = p.getRepoinitText(reference);
+ final List<Operation> ops = parser.parse(new StringReader(repoinitText));
+ log.info("Executing {} repoinit operations", ops.size());
+ processor.apply(s, ops);
+ s.save();
+ }
+ } finally {
+ s.logout();
}
- } finally {
- s.logout();
}
}
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.