diff --git a/CHANGELOG.md b/CHANGELOG.md index ce58cad..e4ea1fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ * The buildpack output will now explicitly mention the installed OpenJDK version instead of displaying only the major version. ([#339](https://github.com/heroku/heroku-buildpack-jvm-common/pull/339) +### Added + +* Support for `DATABASE_URL` values that use the `mariadb` scheme. ([#341](https://github.com/heroku/heroku-buildpack-jvm-common/pull/341) + ## [v159] - 2025-02-17 ### Changed diff --git a/opt/jdbc.sh b/opt/jdbc.sh index f8e60cb..00c3ef5 100644 --- a/opt/jdbc.sh +++ b/opt/jdbc.sh @@ -62,6 +62,9 @@ set_jdbc_url() { "mysql") modified_schema="jdbc:mysql" ;; + "mariadb") + modified_schema="jdbc:mariadb" + ;; *) # We don't handle database URLs that aren't mysql or postgres. # But we also don't consider this an error and silently exit. diff --git a/test/jdbc.sh b/test/jdbc.sh index 0b8f06e..8311d66 100755 --- a/test/jdbc.sh +++ b/test/jdbc.sh @@ -82,6 +82,23 @@ testMySQLDatabaseEnvVar() { ) } +testMariaDBDatabaseEnvVar() { + ( + set -e # Exit subshell after failed command, important to make multi-assert tests work properly + + # Circle CI sets this environment variable. It causes trouble since the JDBC code checks this variable to see if it + # is running on Heroku CI and generates different urls in such cases, causing some tests to fail. + unset CI + + export DATABASE_URL="mariadb://foo:bar@ec2-0-0-0-0:5432/abc123?reconnect=true" + + # shellcheck disable=SC1090 + source "$JDBC_SCRIPT_LOCATION" + + assertEquals "jdbc:mariadb://ec2-0-0-0-0:5432/abc123?password=bar&reconnect=true&user=foo" "$JDBC_DATABASE_URL" + ) +} + testThirdPartyDatabaseUrls() { ( set -e # Exit subshell after failed command, important to make multi-assert tests work properly diff --git a/test/spec/java_spec.rb b/test/spec/java_spec.rb index b2b8c8a..33103d9 100644 --- a/test/spec/java_spec.rb +++ b/test/spec/java_spec.rb @@ -61,7 +61,7 @@ '.profile.d/jvmcommon.sh' => 'f4727529254d7e5bd9f7de2ec110bffe', '.profile.d/default-proc-warning.sh' => 'bb7cd4e1747e2a0c0e9a7137e84d3cf5', '.profile.d/heroku-jvm-metrics.sh' => '9f48b384bc3d9161e45e15906793b191', - '.profile.d/jdbc.sh' => '7a5ce665af22b057c027b1080d2df3d3', + '.profile.d/jdbc.sh' => '7a2abf4a9aaec0b98e3681fbc2d4d215', '.profile.d/jvm-redis.sh' => '7873896b3392a91b35af7dcfad115d6b', '.heroku/with_jmap/bin/java' => 'adc9d1e5abbc1b39d56dc37ce3e26ab8', '.heroku/with_jmap_and_jstack/bin/java' => '5dbd18ed94a0b1f3542ab100f88fd47d',