Repository navigation
Description
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:
spring.application.name: tagged every DC/TP metricapplication="OpenESPI-Common".spring.profiles.active=${SPRING_PROFILES_ACTIVE:dev-mysql}: the TP's defaultlocalstill started asdev-mysql(found in Third Party: make Flyway own the schema in every profile using the openespi-common scripts (split from #241) #267, removed in feat(thirdparty): Flyway owns the Third Party schema in every profile (#267) #272).
Keys still in the file, each a future override:
spring.datasource.username=${DB_USERNAME:root}andspring.datasource.password=${DB_PASSWORD:password}spring.jpa.open-in-view=false,spring.jpa.hibernate.naming.physical-strategy=PhysicalNamingStrategyStandardImplspring.jackson.default-property-inclusion,spring.jackson.datatype.datetime.write-dates-as-timestampsespi.*,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), soSPRING_PROFILES_ACTIVE=dockerorprodcannot 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 indb/migrationplusdb/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
EnvironmentPostProcessorthat 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 thanapplication.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 noapplication-<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.
Activity
fix(thirdparty): address the #272 review (#267)
fix(thirdparty): address the second #272 review (#267)
feat(thirdparty): Flyway owns the Third Party schema in every profile (…