[MAGNOLIA-6104] Modules or config framework should gracefully handle missing paths or missing properties Created: 04/Mar/15  Updated: 04/Mar/19

Status: Open
Project: Magnolia
Component/s: configuration
Affects Version/s: 5.4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Magnolia International Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: development, improvement, ux
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MAGNOLIA-6095 Check if default settings for YamlCon... Open
Template:
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
Story Points: 5

 Description   

Currently, modules do things like

String magnoliaHome = MagnoliaConfigurationProperties.getProperty("magnolia.home");
configSourceFactory.yaml().from(Paths.get(magnoliaHome))

If magnolia.home is not defined, this throws the ugly exception below. There are several things we could do:

  • pass a String of the path to configSourceFactory instead of a Path instance.
  • pass the name of the property, and let configSourceFactory call MagnoliaConfigurationProperties
  • add method to MagnoliaConfigurationProperties to get a Path instance from a property name (can check for existence and it being a directory)
  • add getMagnoliaHome() to MagnoliaInitPaths and make this property a first class citizen. This could also ensure that even if the property isn't defined, we fallback to app-root-dir (rather than relying on the fact that the property exists with its default value, which is indeed ${magnolia.app.rootdir}
    I would tend to favor #4, but there are perhaps more ideas (and/or combinations thereof). Let's update the title of this issue once we decide.
[INFO] [talledLocalContainer] 2015-03-04 11:18:22,784 ERROR info.magnolia.module.ModuleManagerImpl            : Can't start module ui-framework
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] 	at sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:77)
[INFO] [talledLocalContainer] 	at sun.nio.fs.UnixPath.<init>(UnixPath.java:71)
[INFO] [talledLocalContainer] 	at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:281)
[INFO] [talledLocalContainer] 	at java.nio.file.Paths.get(Paths.java:84)
[INFO] [talledLocalContainer] 	at info.magnolia.ui.framework.UiFrameworkModule.start(UiFrameworkModule.java:84)

Generated at Mon Feb 12 04:11:21 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.