SQL: Fix JDBC url pattern in docs and error message (#56612)
The docs pattern url was using `*` which means zero or many instead of `?` which means zero or one. The pattern url returned in error messages was not in sync with the one in the docs. Fixes: #56476 (cherry picked from commit 1a5945c3962cdda21482f4b0b3e0ca508534c2c4)
This commit is contained in:
parent
c10b4ae15a
commit
e781193cf9
|
@ -51,7 +51,7 @@ Once registered, the driver understands the following syntax as an URL:
|
|||
|
||||
["source","text",subs="attributes"]
|
||||
----
|
||||
jdbc:es://[[http|https]://]*[host[:port]]*/[prefix]*<[?[option=value]&]*
|
||||
jdbc:es://[[http|https]://]?[host[:port]]?/[prefix]?[\?[option=value]&]*
|
||||
----
|
||||
`jdbc:es://`:: Prefix. Mandatory.
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ public class JdbcConfiguration extends ConnectionConfiguration {
|
|||
|
||||
private static URI parseUrl(String u) throws JdbcSQLException {
|
||||
String url = u;
|
||||
String format = "jdbc:es://[http|https]?[host[:port]]*/[prefix]*[?[option=value]&]*";
|
||||
String format = "jdbc:es://[[http|https]://]?[host[:port]]?/[prefix]?[\\?[option=value]&]*";
|
||||
if (!canAccept(u)) {
|
||||
throw new JdbcSQLException("Expected [" + URL_PREFIX + "] url, received [" + u + "]");
|
||||
}
|
||||
|
|
|
@ -36,6 +36,12 @@ public class JdbcConfigurationTests extends ESTestCase {
|
|||
return JdbcConfiguration.create(url, null, 0);
|
||||
}
|
||||
|
||||
public void testInvalidUrl() {
|
||||
JdbcSQLException e = expectThrows(JdbcSQLException.class, () -> ci("jdbc:es://localhost9200/?ssl=#5#"));
|
||||
assertEquals("Invalid URL [jdbc:es://localhost9200/?ssl=#5#], format should be " +
|
||||
"[jdbc:es://[[http|https]://]?[host[:port]]?/[prefix]?[\\?[option=value]&]*]", e.getMessage());
|
||||
}
|
||||
|
||||
public void testJustThePrefix() throws Exception {
|
||||
Exception e = expectThrows(JdbcSQLException.class, () -> ci("jdbc:es:"));
|
||||
assertEquals("Expected [jdbc:es://] url, received [jdbc:es:]", e.getMessage());
|
||||
|
|
Loading…
Reference in New Issue