Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Assert() into Warning for db.user/db.password/... #27

Merged
merged 1 commit into from
Mar 18, 2024

Conversation

sheridancbio
Copy link
Contributor

@sheridancbio sheridancbio commented Mar 18, 2024

/- validate all 4 required data source parameters are present (including url)
- use error logging and exception throwing instead of assert()

  • instead of exiting with error, log a warning if deprecated properties are set
    - (the deprectaed properties are currently needed by the msk importer)

This change is needed because the msk importer currently requires the deprecated parameters:
db.user, db.password, db.connection_string, db.portal_db_name, db.host, db.driver

The change of the Assert() statement into a logged warning in JdbcDataSource.java was approved and merged into the cbioportal codebase previously with cBioPortal/cbioportal#10424

This PR also cleans up the code, providing functions for:

  • logging warnings for use of deprecated datasource properties
  • validating the presence of 4 required datasource properties (spring.datasource.url was added)
  • stringIsNullOrBlank

According to the final section notes of https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.10 it is bad practice to handle invalid argument problems through assert() because assert processing is disabled by default but validity of arguments should be checked regardless of whether assertions are enabled or not. Also, an appropriate exception is not thrown by assert(), which causes an AssertionError to be thrown instead. For these reasons, assert() was replaced by throw new RuntimeException(), which causes the construction of the datasource bean to fail during the bean construction stage of context creation, exiting the application.

Note : this PR replaced #26 because currently, pull requests across forks seems to cause a failure in the CI tests (updating dependencies in the manifest / maven.yml)

- validate all 4 required data source parameters are present (including url)
	- use error logging and exception throwing instead of assert()
- instead of exiting with error, log a warning if deprecated properties are set
	(the deprectaed properties are currently needed by the msk importer)
@sheridancbio sheridancbio added bug Something isn't working enhancement New feature or request labels Mar 18, 2024
Copy link
Contributor

@mandawilson mandawilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Rob!

@JREastonMarks JREastonMarks merged commit e388941 into main Mar 18, 2024
4 of 5 checks passed
@JREastonMarks JREastonMarks deleted the datasource-properties-validation branch March 18, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants