Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Sling Models Impl 1.2.4
Description
SLING-4161 introduced a special handling for postconstruct errors (in ModelAdapterFactory):
public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) { Result<AdapterType> result = internalCreateModel(adaptable, type); if (!result.wasSuccessfull()) { // treat post-construct and validation exceptions differently, because they are sometimes used for flow-control or validation purposes if (result.getThrowable() instanceof PostConstructException || result.getThrowable() instanceof InvalidModelException) { log.debug("Could not adapt to model", result.getThrowable()); } else { log.error("Could not adapt to model", result.getThrowable()); } return null; } else { return result.getValue(); } }
that means that all exceptions that are caught in a @PostConstruct annotated method are logged only in debug level. even if it's only a NPE in the code.
this makes identifying errors in PostConstruct methods very hard. we need to come up with a better solution to differentiate between validation errors not to log as errors and real errors like an NPE.
Attachments
Issue Links
- is broken by
-
SLING-4767 Optional sub models are logged as warn if they cannot be adapted
- Closed
- is related to
-
SLING-8079 Returning false in a model PostConstruct causes an java.lang.IllegalStateException
- Closed
- relates to
-
SLING-9478 Expose the full stack trace for PostConstruct exceptions
- Resolved
-
SLING-4161 Support Sling Validation through a new field of the Model annotation
- Closed