[MAGNOLIA-3825] Module mechanism fails on modules with only optional-and-not-present dependencies Created: 07/Sep/11  Updated: 14/Dec/11  Resolved: 15/Nov/11

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 4.4.4
Fix Version/s: 4.4.6

Type: Bug Priority: Neutral
Reporter: Magnolia International Assignee: Milan Divilek
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File MAGNOLIA-3825.patch    
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Testcase included:
Yes
Date of First Response:

 Description   

If a module has only optional dependencies, and none of those is present in the current system, the current dependency calculation blows up with the following exception

java.util.NoSuchElementException
	at java.util.AbstractList$Itr.next(AbstractList.java:350)
	at java.util.Collections.max(Collections.java:640)
	at info.magnolia.module.model.reader.DependencyLevelComparator.calcDependencyDepth(DependencyLevelComparator.java:110)
	at info.magnolia.module.model.reader.DependencyLevelComparator.compare(DependencyLevelComparator.java:76)
	at info.magnolia.module.model.reader.DependencyLevelComparator.compare(DependencyLevelComparator.java:52)
	at java.util.Arrays.mergeSort(Arrays.java:1270)
	at java.util.Arrays.mergeSort(Arrays.java:1281)
	at java.util.Arrays.mergeSort(Arrays.java:1281)
	at java.util.Arrays.mergeSort(Arrays.java:1282)
	at java.util.Arrays.sort(Arrays.java:1210)
	at java.util.Collections.sort(Collections.java:159)
	at info.magnolia.module.model.reader.DependencyCheckerImpl.sortByDependencyLevel(DependencyCheckerImpl.java:65)
	at info.magnolia.module.ModuleManagerImpl.loadDefinitions(ModuleManagerImpl.java:141)

Here's a patch and test that fixes the issue.
The attached test fails with 4.4.4.



 Comments   
Comment by Milan Divilek [ 15/Nov/11 ]

Need add some test

Generated at Mon Feb 12 03:50:02 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.