Fix start-dev mode on Windows by avoiding backslashes escaping expressions
Closes #17413
This commit is contained in:
parent
4bfa3c7a1a
commit
4cf5c11020
1 changed files with 12 additions and 2 deletions
|
@ -107,13 +107,23 @@ public final class Database {
|
||||||
@Override
|
@Override
|
||||||
public String apply(String alias) {
|
public String apply(String alias) {
|
||||||
if ("dev-file".equalsIgnoreCase(alias)) {
|
if ("dev-file".equalsIgnoreCase(alias)) {
|
||||||
return addH2NonKeywords("jdbc:h2:file:${kc.home.dir:${kc.db-url-path:" + System.getProperty("user.home") + "}}" + File.separator + "${kc.data.dir:data}"
|
return addH2NonKeywords("jdbc:h2:file:${kc.home.dir:${kc.db-url-path:" + escapeReplacements(System.getProperty("user.home")) + "}}" + escapeReplacements(File.separator) + "${kc.data.dir:data}"
|
||||||
+ File.separator + "h2" + File.separator
|
+ escapeReplacements(File.separator) + "h2" + escapeReplacements(File.separator)
|
||||||
+ "keycloakdb${kc.db-url-properties:;;AUTO_SERVER=TRUE}");
|
+ "keycloakdb${kc.db-url-properties:;;AUTO_SERVER=TRUE}");
|
||||||
}
|
}
|
||||||
return addH2NonKeywords("jdbc:h2:mem:keycloakdb${kc.db-url-properties:}");
|
return addH2NonKeywords("jdbc:h2:mem:keycloakdb${kc.db-url-properties:}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String escapeReplacements(String snippet) {
|
||||||
|
if (File.separator.equals("\\")) {
|
||||||
|
// SmallRye will do replacements of "${...}", but a "\" must not escape such an expression.
|
||||||
|
// As we nest multiple expressions, and each nested expression must re-escape the backslashes,
|
||||||
|
// the simplest way is to replace a backslash with a slash, as those are processed nicely on Windows.
|
||||||
|
return snippet.replace("\\", "/");
|
||||||
|
}
|
||||||
|
return snippet;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starting with H2 version 2.x, marking "VALUE" as a non-keyword is necessary as some columns are named "VALUE" in the Keycloak schema.
|
* Starting with H2 version 2.x, marking "VALUE" as a non-keyword is necessary as some columns are named "VALUE" in the Keycloak schema.
|
||||||
* <p />
|
* <p />
|
||||||
|
|
Loading…
Reference in a new issue