Fix Liquibase AttachmentVersionNumberMigration failure when system property is not provided or was set wrongly (a String "null" and not null) (#4632)

When system property is not provided or was set wrongly (a String with text "null" and not null reference).
This commit is contained in:
szymonsztuka
2019-01-24 18:19:39 +00:00
committed by GitHub
parent 16d53505d7
commit f7a6463424
2 changed files with 7 additions and 5 deletions

View File

@ -28,9 +28,9 @@ class AttachmentVersionNumberMigration : CustomTaskChange {
try {
logger.info("Start executing...")
var networkParameters: NetworkParameters?
if (System.getProperty(NODE_BASE_DIR_KEY).isNotEmpty()) {
val path = Paths.get(System.getProperty(NODE_BASE_DIR_KEY)) / NETWORK_PARAMS_FILE_NAME
val baseDir = System.getProperty(SchemaMigration.NODE_BASE_DIR_KEY)
if (baseDir != null) {
val path = Paths.get(baseDir) / NETWORK_PARAMS_FILE_NAME
networkParameters = getNetworkParametersFromFile(path)
if (networkParameters != null) {
logger.info("$msg using network parameters from $path, whitelistedContractImplementations: ${networkParameters.whitelistedContractImplementations}.")

View File

@ -89,8 +89,10 @@ class SchemaMigration(
}
}
System.setProperty(NODE_BASE_DIR_KEY, currentDirectory.toString()) // base dir for any custom change set which may need to load a file (currently AttachmentVersionNumberMigration)
val path = currentDirectory?.toString()
if (path != null) {
System.setProperty(NODE_BASE_DIR_KEY, path) // base dir for any custom change set which may need to load a file (currently AttachmentVersionNumberMigration)
}
val customResourceAccessor = CustomResourceAccessor(dynamicInclude, changelogList, classLoader)
val liquibase = Liquibase(dynamicInclude, customResourceAccessor, getLiquibaseDatabase(JdbcConnection(connection)))