RED-5293: fixed jdbcUrl-check by adding URL check

This commit is contained in:
Ali Oezyetimoglu 2022-11-10 12:55:36 +01:00
parent 907d88f658
commit 39a0eb4f8d

View File

@ -1,5 +1,6 @@
package com.iqser.red.service.peristence.v1.server.service;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.sql.Connection;
@ -132,10 +133,14 @@ public class TenantManagementService {
@SneakyThrows
private void validateJdbcUrl(String jdbcUrl) {
// just create a URL object to check if the string is a valid URL
new URL(jdbcUrl);
// same as above but with a URI object
// just create a URI object to check if the string is a valid URI
new URI(jdbcUrl);
// same as above but with a URL object
try {
new URL(jdbcUrl);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Your jdbcUrl is not URL conform.", e);
}
}