From d8463bb84bfcd2f689f6f7781c138d06e9c37085 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Thu, 5 Jan 2023 11:21:14 +0100 Subject: [PATCH] GH-102 - Avoid topological sorting to fail on cyclic module graphs. We now fall back to the default non-topological ordering in case the application module graph contains cycles. --- .../modulith/model/ApplicationModules.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java b/spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java index c546653c..0c2b05ba 100644 --- a/spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java +++ b/spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java @@ -554,10 +554,16 @@ public class ApplicationModules implements Iterable { }); var names = new ArrayList(); + var iterator = new TopologicalOrderIterator<>(graph); - new TopologicalOrderIterator<>(graph).forEachRemaining(it -> names.add(0, it.getName())); + try { - return names; + iterator.forEachRemaining(it -> names.add(0, it.getName())); + return names; + + } catch (IllegalArgumentException o_O) { + return modules.modules.values().stream().map(ApplicationModule::getName).toList(); + } } } }