[cleanup] Combine nested 'if' within 'else' block to 'else if'

Cleanup performed on bundles
- org.eclipse.core.expressions
- org.eclipse.core.jobs
- org.eclipse.e4.core.contexts
- org.eclipse.e4.core.di
- org.eclipse.e4.core.services
- org.eclipse.core.tests.runtime

Also added {} to ExpressionInfo, ThreadJob for blocks via JDT cleanup
action

Change-Id: Id8b61075b34c575a2afaa55248390e17967dce6d
Signed-off-by: Karsten Thoms <karsten.thoms@karakun.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.runtime/+/172239
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionInfo.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionInfo.java
index d54f982..d78c112 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionInfo.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionInfo.java
@@ -80,8 +80,9 @@
 	 * @return the set of accessed variables
 	 */
 	public String[] getAccessedVariableNames() {
-		if (fAccessedVariableNames == null)
+		if (fAccessedVariableNames == null) {
 			return new String[0];
+		}
 		return fAccessedVariableNames.toArray(new String[fAccessedVariableNames.size()]);
 	}
 
@@ -94,9 +95,8 @@
 		if (fAccessedVariableNames == null) {
 			fAccessedVariableNames= new ArrayList<>(5);
 			fAccessedVariableNames.add(name);
-		} else {
-			if (!fAccessedVariableNames.contains(name))
-				fAccessedVariableNames.add(name);
+		} else if (!fAccessedVariableNames.contains(name)) {
+			fAccessedVariableNames.add(name);
 		}
 	}
 
@@ -109,8 +109,9 @@
 	 * @since 3.4
 	 */
 	public String[] getAccessedPropertyNames() {
-		if (fAccessedPropertyNames == null)
+		if (fAccessedPropertyNames == null) {
 			return new String[0];
+		}
 		return fAccessedPropertyNames.toArray(new String[fAccessedPropertyNames.size()]);
 	}
 
@@ -128,9 +129,9 @@
 		if (fAccessedPropertyNames == null) {
 			fAccessedPropertyNames= new ArrayList<>(5);
 			fAccessedPropertyNames.add(name);
-		} else {
-			if (!fAccessedPropertyNames.contains(name))
-				fAccessedPropertyNames.add(name);
+		} else if (!fAccessedPropertyNames.contains(name))
+		{
+			fAccessedPropertyNames.add(name);
 		}
 	}
 
@@ -145,8 +146,9 @@
 	 *  <code>computeReevaluationInfo</code> method, or <code>null</code> if all do
 	 */
 	public Class<?>[] getMisbehavingExpressionTypes() {
-		if (fMisbehavingExpressionTypes == null)
+		if (fMisbehavingExpressionTypes == null) {
 			return null;
+		}
 		return fMisbehavingExpressionTypes.toArray(new Class[fMisbehavingExpressionTypes.size()]);
 	}
 
@@ -159,9 +161,8 @@
 		if (fMisbehavingExpressionTypes == null) {
 			fMisbehavingExpressionTypes= new ArrayList<>(2);
 			fMisbehavingExpressionTypes.add(clazz);
-		} else {
-			if (!fMisbehavingExpressionTypes.contains(clazz))
-				fMisbehavingExpressionTypes.add(clazz);
+		} else if (!fMisbehavingExpressionTypes.contains(clazz)) {
+			fMisbehavingExpressionTypes.add(clazz);
 		}
 	}
 
@@ -219,11 +220,10 @@
 	private void mergeAccessedVariableNames(ExpressionInfo other) {
 		if (fAccessedVariableNames == null) {
 			fAccessedVariableNames= other.fAccessedVariableNames; //TODO: shares the two lists! Can propagate further additions up into sibling branches.
-		} else {
-			if (other.fAccessedVariableNames != null) {
-				for (String variableName : other.fAccessedVariableNames) {
-					if (!fAccessedVariableNames.contains(variableName))
-						fAccessedVariableNames.add(variableName);
+		} else if (other.fAccessedVariableNames != null) {
+			for (String variableName : other.fAccessedVariableNames) {
+				if (!fAccessedVariableNames.contains(variableName)) {
+					fAccessedVariableNames.add(variableName);
 				}
 			}
 		}
@@ -239,11 +239,10 @@
 	private void mergeAccessedPropertyNames(ExpressionInfo other) {
 		if (fAccessedPropertyNames == null) {
 			fAccessedPropertyNames= other.fAccessedPropertyNames; //TODO: shares the two lists!
-		} else {
-			if (other.fAccessedPropertyNames != null) {
-				for (String variableName : other.fAccessedPropertyNames) {
-					if (!fAccessedPropertyNames.contains(variableName))
-						fAccessedPropertyNames.add(variableName);
+		} else if (other.fAccessedPropertyNames != null) {
+			for (String variableName : other.fAccessedPropertyNames) {
+				if (!fAccessedPropertyNames.contains(variableName)) {
+					fAccessedPropertyNames.add(variableName);
 				}
 			}
 		}
@@ -257,11 +256,10 @@
 	private void mergeMisbehavingExpressionTypes(ExpressionInfo other) {
 		if (fMisbehavingExpressionTypes == null) {
 			fMisbehavingExpressionTypes= other.fMisbehavingExpressionTypes; //TODO: shares the two lists!
-		} else  {
-			if (other.fMisbehavingExpressionTypes != null) {
-				for (Class<?> clazz : other.fMisbehavingExpressionTypes) {
-					if (!fMisbehavingExpressionTypes.contains(clazz))
-						fMisbehavingExpressionTypes.add(clazz);
+		} else if (other.fMisbehavingExpressionTypes != null) {
+			for (Class<?> clazz : other.fMisbehavingExpressionTypes) {
+				if (!fMisbehavingExpressionTypes.contains(clazz)) {
+					fMisbehavingExpressionTypes.add(clazz);
 				}
 			}
 		}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Expressions.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Expressions.java
index 0bc774b..3dc03ad 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Expressions.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Expressions.java
@@ -316,12 +316,10 @@
 			if (ch == '\'') {
 				if (!inString) {
 					inString= true;
+				} else if (i + 1 < str.length() && str.charAt(i + 1) == '\'') {
+					i++;
 				} else {
-					if (i + 1 < str.length() && str.charAt(i + 1) == '\'') {
-						i++;
-					} else {
-						inString= false;
-					}
+					inString= false;
 				}
 			} else if (ch == ',' && !inString) {
 				return i;
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java
index dbfd414..72750d4 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java
@@ -207,12 +207,10 @@
 			}
 			if (count > 0) {
 				return result;
+			} else if (fEmptyResult == null) {
+				return fOperator == AND ? EvaluationResult.TRUE : EvaluationResult.FALSE;
 			} else {
-				if (fEmptyResult == null) {
-					return fOperator == AND ? EvaluationResult.TRUE : EvaluationResult.FALSE;
-				} else {
-					return fEmptyResult.booleanValue() ? EvaluationResult.TRUE : EvaluationResult.FALSE;
-				}
+				return fEmptyResult.booleanValue() ? EvaluationResult.TRUE : EvaluationResult.FALSE;
 			}
 		}
 	}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtension.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtension.java
index 5934ba9..41a4f15 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtension.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtension.java
@@ -93,27 +93,25 @@
 				// we don't have to support stop in 3.2. If we have to in the future we have to
 				// reactivate the stopped plug-in if we are in forcePluginActivation mode.
 				return extender;
-			} else {
-				if (extender.isDeclaringPluginActive() || forcePluginActivation) {
-					try {
-						PropertyTesterDescriptor descriptor= (PropertyTesterDescriptor)extender;
-						IPropertyTester inst= descriptor.instantiate();
-						((PropertyTester)inst).internalInitialize(descriptor);
-						fExtenders[i]= extender= inst;
-						return extender;
-					} catch (CoreException e) {
-						fExtenders[i]= null;
-						throw e;
-					} catch (ClassCastException e) {
-						fExtenders[i]= null;
-						throw new CoreException(new ExpressionStatus(
-							ExpressionStatus.TYPE_EXTENDER_INCORRECT_TYPE,
-							ExpressionMessages.TypeExtender_incorrectType,
-							e));
-					}
-				} else {
+			} else if (extender.isDeclaringPluginActive() || forcePluginActivation) {
+				try {
+					PropertyTesterDescriptor descriptor= (PropertyTesterDescriptor)extender;
+					IPropertyTester inst= descriptor.instantiate();
+					((PropertyTester)inst).internalInitialize(descriptor);
+					fExtenders[i]= extender= inst;
 					return extender;
+				} catch (CoreException e) {
+					fExtenders[i]= null;
+					throw e;
+				} catch (ClassCastException e) {
+					fExtenders[i]= null;
+					throw new CoreException(new ExpressionStatus(
+						ExpressionStatus.TYPE_EXTENDER_INCORRECT_TYPE,
+						ExpressionMessages.TypeExtender_incorrectType,
+						e));
 				}
+			} else {
+				return extender;
 			}
 		}
 
diff --git a/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
index 8288353..df47189 100644
--- a/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
+++ b/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
@@ -102,11 +102,11 @@
 		if (top >= 0 && top < ruleStack.length) {
 			buf.append(", does not match most recent begin: "); //$NON-NLS-1$
 			buf.append(ruleStack[top]);
-		} else {
-			if (top < 0)
-				buf.append(", but there was no matching beginRule"); //$NON-NLS-1$
-			else
-				buf.append(", but the rule stack was out of bounds: " + top); //$NON-NLS-1$
+		} else if (top < 0) {
+			buf.append(", but there was no matching beginRule"); //$NON-NLS-1$
+		}
+		else {
+			buf.append(", but the rule stack was out of bounds: " + top); //$NON-NLS-1$
 		}
 		buf.append(".  See log for trace information if rule tracing is enabled."); //$NON-NLS-1$
 		String msg = buf.toString();
@@ -191,8 +191,9 @@
 	 * @throws OperationCanceledException if this job was canceled before it was started.
 	 */
 	static ThreadJob joinRun(ThreadJob threadJob, IProgressMonitor monitor) {
-		if (isCanceled(monitor))
+		if (isCanceled(monitor)) {
 			throw new OperationCanceledException();
+		}
 		// check if there is a blocking thread before waiting
 		InternalJob blockingJob = manager.findBlockingJob(threadJob);
 		Thread blocker = blockingJob == null ? null : blockingJob.getThread();
@@ -200,8 +201,9 @@
 		boolean interruptedDuringWaitForRun;
 		try {
 			// just return if lock listener decided to grant immediate access
-			if (manager.getLockManager().aboutToWait(blocker))
+			if (manager.getLockManager().aboutToWait(blocker)) {
 				return threadJob;
+			}
 			result = waitForRun(threadJob, monitor, blockingJob);
 		} finally {
 			// We need to check for interruption unconditionally in order to
@@ -257,8 +259,9 @@
 			// to respond to cancellation, register this monitor with the internal JobManager
 			// worker thread. The worker thread will check for cancellation and will interrupt
 			// this thread when the monitor is canceled. T
-			if (canBlock)
+			if (canBlock) {
 				manager.beginMonitoring(threadJob, monitor);
+			}
 			final Thread currentThread = Thread.currentThread();
 
 			// Ultimately, this loop will wait until the job "runs" (acquires the rule)
@@ -273,9 +276,10 @@
 			// 4) Monitor is canceled.
 			while (true) {
 				// monitor is foreign code so do not hold locks while calling into monitor
-				if (interrupted || isCanceled(monitor))
+				if (interrupted || isCanceled(monitor)) {
 					// Condition #4.
 					throw new OperationCanceledException();
+				}
 				// Try to run the job. If result is null, this job was allowed to run.
 				// If the result is successful, atomically release thread from waiting
 				// status.
@@ -299,9 +303,10 @@
 					return result;
 				}
 				// just return if lock listener decided to grant immediate access
-				if (manager.getLockManager().aboutToWait(blocker))
+				if (manager.getLockManager().aboutToWait(blocker)) {
 					// Condition #2.
 					return threadJob;
+				}
 
 				// Notify the lock manager that we're about to block waiting for the scheduling rule
 				manager.getLockManager().addLockWaitThread(currentThread, threadJob.getRule());
@@ -312,10 +317,11 @@
 						// this while loop
 						int state = blockingJob.getState();
 						//ensure we don't wait forever if the blocker is waiting, because it might have yielded to me
-						if (state == Job.RUNNING && canBlock)
+						if (state == Job.RUNNING && canBlock) {
 							blockingJob.jobStateLock.wait();
-						else if (state != Job.NONE)
+						} else if (state != Job.NONE) {
 							blockingJob.jobStateLock.wait(250);
+						}
 					} catch (InterruptedException e) {
 						// This thread may be interrupted via two common scenarios. 1) If
 						// the UISynchronizer is in use and this thread is a UI thread
@@ -349,8 +355,9 @@
 			}
 			waitEnd(threadJob, updateLockState, monitor);
 			if (canStopWaiting) {
-				if (waiting)
+				if (waiting) {
 					manager.implicitJobs.removeWaiting(threadJob);
+				}
 			}
 			if (canBlock) {
 				// must unregister monitoring this job
@@ -365,8 +372,9 @@
 	 * 	@GuardedBy("JobManager.implicitJobs")
 	 */
 	boolean pop(ISchedulingRule rule) {
-		if (top < 0 || ruleStack[top] != rule)
+		if (top < 0 || ruleStack[top] != rule) {
 			illegalPop(rule);
+		}
 		ruleStack[top--] = null;
 		return top < 0;
 	}
@@ -385,11 +393,13 @@
 			ruleStack = newStack;
 		}
 		ruleStack[top] = rule;
-		if (JobManager.DEBUG_BEGIN_END)
+		if (JobManager.DEBUG_BEGIN_END) {
 			lastPush = (RuntimeException) new RuntimeException().fillInStackTrace();
+		}
 		//check for containment last because we don't want to fail again on endRule
-		if (baseRule != null && rule != null && !(baseRule.contains(rule) && baseRule.isConflicting(rule)))
+		if (baseRule != null && rule != null && !(baseRule.contains(rule) && baseRule.isConflicting(rule))) {
 			illegalPush(rule, baseRule);
+		}
 	}
 
 	/**
@@ -399,17 +409,19 @@
 	 */
 	boolean recycle() {
 		//don't recycle if still running for any reason
-		if (getState() != Job.NONE)
+		if (getState() != Job.NONE) {
 			return false;
+		}
 		//clear and reset all fields
 		acquireRule = isRunning = isBlocked = false;
 		realJob = null;
 		setRule(null);
 		setThread(null);
-		if (ruleStack.length != 2)
+		if (ruleStack.length != 2) {
 			ruleStack = new ISchedulingRule[2];
-		else
+		} else {
 			ruleStack[0] = ruleStack[1] = null;
+		}
 		top = -1;
 		return true;
 	}
@@ -455,8 +467,9 @@
 		buf.append('[');
 		for (int i = 0; i <= top && i < ruleStack.length; i++) {
 			buf.append(ruleStack[i]);
-			if (i != top)
+			if (i != top) {
 				buf.append(',');
+			}
 		}
 		buf.append(']');
 		return buf.toString();
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java
index 8347a3e..bd4b0e9 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java
@@ -166,14 +166,12 @@
 			} else { // we do track if this is done inside a computation, but don't create another runnable
 				fillArgs(actualArgs, keys, active);
 			}
-		} else {
-			if (descriptors.length > 0) {
-				pauseRecording();
-				try {
-					fillArgs(actualArgs, keys, active);
-				} finally {
-					resumeRecording();
-				}
+		} else if (descriptors.length > 0) {
+			pauseRecording();
+			try {
+				fillArgs(actualArgs, keys, active);
+			} finally {
+				resumeRecording();
 			}
 		}
 	}
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/TrackableComputationExt.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/TrackableComputationExt.java
index bfa3497..638dee7 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/TrackableComputationExt.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/TrackableComputationExt.java
@@ -93,20 +93,16 @@
 					result = ((RunAndTrackExt) runnable).update(event.getContext(), event.getEventType(), event.getArguments());
 					if (eventType != ContextChangeEvent.DISPOSE && eventType != ContextChangeEvent.UNINJECTED)
 						cachedEvent = null;
-				} else {
-					if (eventType != ContextChangeEvent.DISPOSE && eventType != ContextChangeEvent.UNINJECTED) {
-						result = runnable.changed(originatingContext);
-						cachedEvent = null;
-					}
+				} else if (eventType != ContextChangeEvent.DISPOSE && eventType != ContextChangeEvent.UNINJECTED) {
+					result = runnable.changed(originatingContext);
+					cachedEvent = null;
 				}
 			}
 			if (eventType != ContextChangeEvent.UPDATE) {
 				if (runnable instanceof RunAndTrackExt)
 					result = ((RunAndTrackExt) runnable).update(event.getContext(), event.getEventType(), event.getArguments());
-				else {
-					if (eventType != ContextChangeEvent.DISPOSE && eventType != ContextChangeEvent.UNINJECTED)
-						result = runnable.changed(originatingContext);
-				}
+				else if (eventType != ContextChangeEvent.DISPOSE && eventType != ContextChangeEvent.UNINJECTED)
+					result = runnable.changed(originatingContext);
 			}
 		} finally {
 			((EclipseContext) originatingContext).popComputation(this);
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
index 7ec5ccd..53da335 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
@@ -210,18 +210,16 @@
 				if (unresolved == -1) {
 					requestor.setResolvedArgs(actualArgs);
 					requestor.execute();
-				} else {
-					if (requestor.isOptional())
-						requestor.setResolvedArgs(null);
-					else if (shouldDebug) {
-						StringBuilder tmp = new StringBuilder();
-						tmp.append("Uninjecting object \""); //$NON-NLS-1$
-						tmp.append(object.toString());
-						tmp.append("\": dependency on \""); //$NON-NLS-1$
-						tmp.append(requestor.getDependentObjects()[unresolved].toString());
-						tmp.append("\" is not optional."); //$NON-NLS-1$
-						LogHelper.logError(tmp.toString(), null);
-					}
+				} else if (requestor.isOptional())
+					requestor.setResolvedArgs(null);
+				else if (shouldDebug) {
+					StringBuilder tmp = new StringBuilder();
+					tmp.append("Uninjecting object \""); //$NON-NLS-1$
+					tmp.append(object.toString());
+					tmp.append("\": dependency on \""); //$NON-NLS-1$
+					tmp.append(requestor.getDependentObjects()[unresolved].toString());
+					tmp.append("\" is not optional."); //$NON-NLS-1$
+					LogHelper.logError(tmp.toString(), null);
 				}
 			}
 		} catch (NoClassDefFoundError | NoSuchMethodError e) {
@@ -426,13 +424,11 @@
 		int unresolved = unresolved(actualArgs);
 		if (unresolved == -1)
 			internalRequestor.setResolvedArgs(actualArgs);
+		else if (internalRequestor.isOptional())
+			internalRequestor.setResolvedArgs(null);
 		else {
-			if (internalRequestor.isOptional())
-				internalRequestor.setResolvedArgs(null);
-			else {
-				String msg = resolutionError(internalRequestor, unresolved);
-				LogHelper.logError(msg, null);
-			}
+			String msg = resolutionError(internalRequestor, unresolved);
+			LogHelper.logError(msg, null);
 		}
 	}
 
diff --git a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
index 202b5f9..30dbbc6 100644
--- a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
+++ b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
@@ -185,10 +185,8 @@
 			// remove the leading /
 			if (uri.getPath() != null && !uri.getPath().isEmpty()) {
 				classPath = uri.getPath().substring(1);
-			} else {
-				if (logger != null) {
-					logger.error("Called with invalid contribution URI: {}", contributionURI); //$NON-NLS-1$
-				}
+			} else if (logger != null) {
+				logger.error("Called with invalid contribution URI: {}", contributionURI); //$NON-NLS-1$
 			}
 		}
 
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
index d0ad86d..09ee0ea 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
@@ -1619,10 +1619,8 @@
 			int state = family2[i].getState();
 			if (state == Job.RUNNING) {
 				runningCount++;
-			} else {
-				if (state != Job.WAITING) {
-					assertTrue("4.2." + i + ": expected state: " + printState(Job.WAITING) + " actual state: " + printState(state), false);
-				}
+			} else if (state != Job.WAITING) {
+				assertTrue("4.2." + i + ": expected state: " + printState(Job.WAITING) + " actual state: " + printState(state), false);
 			}
 		}
 		//ensure only one job is running (it is possible that none have started yet)
@@ -1651,10 +1649,8 @@
 			int state = family1[i].getState();
 			if (state == Job.RUNNING) {
 				runningCount++;
-			} else {
-				if (state != Job.WAITING) {
-					assertTrue("7.1." + i + ": expected state: " + printState(Job.WAITING) + " actual state: " + printState(state), false);
-				}
+			} else if (state != Job.WAITING) {
+				assertTrue("7.1." + i + ": expected state: " + printState(Job.WAITING) + " actual state: " + printState(state), false);
 			}
 		}
 		//ensure only one job is running (it is possible that none have started yet)