Skip to content

openespi-common: its jar's application.properties overrides each application's application.yml #273

Open

Description

@dfcoffin

Problem

openespi-common ships src/main/resources/application.properties inside its jar. It sits at the same classpath location as each consuming application's own application.yml, and for files at the same location Spring Boot gives .properties precedence over .yml. So every key in the library's file silently overrides the same key in the Data Custodian's and Third Party's application.yml.

This has bitten twice already, and both times the fix was to delete one key:

Keys still in the file, each a future override:

  • spring.datasource.username=${DB_USERNAME:root} and spring.datasource.password=${DB_PASSWORD:password}
  • spring.jpa.open-in-view=false, spring.jpa.hibernate.naming.physical-strategy=PhysicalNamingStrategyStandardImpl
  • spring.jackson.default-property-inclusion, spring.jackson.datatype.datetime.write-dates-as-timestamps
  • espi.*, greenbutton.*, logging.pattern.console

The library's profile files too

openespi-common also ships application-docker.yml, application-prod.yml and application-aws-sandbox.yml at the jar root. They are on the classpath of the Data Custodian and the Third Party, and they are broken:

  • Each sets spring.profiles.active (docker, prod, aws-sandbox) inside a profile-specific file. Spring Boot rejects that (InvalidConfigDataPropertyException), so SPRING_PROFILES_ACTIVE=docker or prod cannot start either application.
  • Each points Flyway at classpath:db/migration/mysql (prod: ${FLYWAY_LOCATIONS:classpath:db/migration/mysql}). That folder does not exist; the scripts are in db/migration plus db/vendor/{h2,mysql,postgres}.

They predate #272 (found in its second review). Delete them, or move what each application needs into its own profile files.

Proposed fix

Stop shipping a default-named application.properties in the library jar. Two options:

  • Move the defaults into a common auto-configuration, or an EnvironmentPostProcessor that adds them as a lowest-precedence property source, so any application value wins.
  • Or rename the file (e.g. openespi-common-defaults.properties) and load it with @PropertySource, which also has lower precedence than application.yml.

Then decide per key whether it belongs in the library at all. root/password datasource credentials probably don't.

Acceptance

  • No application.properties / application.yml, and no application-<profile>.yml, at the root of the openespi-common jar.
  • A DC and a TP test show an application-level value (e.g. the naming strategy, or a Jackson option) wins over the library default.
  • openespi-common's own tests still get the defaults they need (from src/test/resources).

The Authorization Server doesn't depend on openespi-common and is unaffected.

Found in the review of #272.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions