Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15218

Log failures to load PropertySources when ignoreResourceNotFound = true

    XMLWordPrintable

    Details

      Description

      In ConfigurationClassParser.processPropertySource(), if ignoreResourceNotFound is set to true for a given property source and that property source is not loadable (e.g. because the file does not exist), no message is currently logged by Spring at any level.

      This can make it extremely difficult to debug unexpected behaviour in property source resolution. For example, see the Repro main class in the referenced project on GitHub, which has a PropertySource referring to a non-existent property file.

      The ultimate output of this program is myProp = ${mykey}, because the config file is not found and therefore the "mykey" variable substitution does not occur.

      However, if the developer was expecting the config file to exist, and hence was surprised at the lack of variable substitution, the cause would be very difficult to diagnose from the application logs, because even at the highest level of logging, there is no message to indicate that Spring tried and failed to open does-not-exist.properties. Of course, real-world scenarios would probably be much more complex.

      I propose that Spring's ConfigurationClassParser should be changed to log a message at debug level when a PropertySource with ignoreResourceNotFound = true cannot be loaded for any reason.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              amedworth Andrew Medworth
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 1 week ago