Skip to content

Commit 4a0f26e

Browse files
committed
Enforce precondition in TestDescriptor.accept(Visitor)
1 parent 5df9b98 commit 4a0f26e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

junit-platform-engine/src/main/java/org/junit/platform/engine/TestDescriptor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,12 @@ default void prune() {
240240
Optional<? extends TestDescriptor> findByUniqueId(UniqueId uniqueId);
241241

242242
/**
243-
* Accept a visitor to the subtree starting with this descriptor.
243+
* Accept a {@link Visitor} to the subtree starting with this descriptor.
244244
*
245245
* @param visitor the {@code Visitor} to accept; never {@code null}
246246
*/
247247
default void accept(Visitor visitor) {
248+
Preconditions.notNull(visitor, "Visitor must not be null");
248249
visitor.visit(this);
249250
// Create a copy of the set in order to avoid a ConcurrentModificationException
250251
new LinkedHashSet<>(this.getChildren()).forEach(child -> child.accept(visitor));
@@ -253,7 +254,7 @@ default void accept(Visitor visitor) {
253254
/**
254255
* Visitor for the tree-like {@link TestDescriptor} structure.
255256
*
256-
* @see TestDescriptor#accept
257+
* @see TestDescriptor#accept(Visitor)
257258
*/
258259
@FunctionalInterface
259260
interface Visitor {
@@ -264,6 +265,7 @@ interface Visitor {
264265
* @param descriptor the {@code TestDescriptor} to visit; never {@code null}
265266
*/
266267
void visit(TestDescriptor descriptor);
268+
267269
}
268270

269271
/**

0 commit comments

Comments
 (0)