Meaningful error message if project has no parent in source
Import of All-Projects was failing with an NPE on import of
All-Projects if no parent project in target was specified.
Change-Id: Ia571bd0cca87dcf2fa41e845e05fb5dcf78b3900
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
index 02a75ae..bc8061e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
@@ -288,6 +288,11 @@
private void checkPreconditions(ProgressMonitor pm) throws BadRequestException {
pm.beginTask("Check preconditions", 1);
+ if (parent == null) {
+ throw new BadRequestException(
+ "The project has no parent in the source system. "
+ + "It can only be imported if a parent project is specified.");
+ }
ProjectState p = projectCache.get(parent);
if (p == null) {
throw new BadRequestException(format(