Skip to content

Commit

Permalink
[CONJ-219] User passed from HikariConfig becomes null if done with pr…
Browse files Browse the repository at this point in the history
…operties
  • Loading branch information
rusher committed Nov 19, 2015
1 parent 7900eb9 commit da75bf7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>1.3.1</version>
<version>1.3.2-SNAPSHOT</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

Expand All @@ -26,11 +26,11 @@
</license>
</licenses>

<scm>
<connection>scm:git:git://github.com/MariaDB/mariadb-connector-j.git</connection>
<url>https://github.com/MariaDB/mariadb-connector-j</url>
<developerConnection>scm:git:git@github.com:MariaDB/mariadb-connector-j.git</developerConnection>
</scm>
<!--<scm>-->
<!--<connection>scm:git:git://github.com/MariaDB/mariadb-connector-j.git</connection>-->
<!--<url>https://github.com/MariaDB/mariadb-connector-j</url>-->
<!--<developerConnection>scm:git:git@github.com:MariaDB/mariadb-connector-j.git</developerConnection>-->
<!--</scm>-->

<issueManagement>
<system>JIRA</system>
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/mariadb/jdbc/UrlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
public class UrlParser {

private String database;
private Options options;
private Options options = null;
private List<HostAddress> addresses;
private HaMode haMode;

Expand Down Expand Up @@ -181,8 +181,10 @@ private static void parseInternal(UrlParser urlParser, String url, Properties pr
urlParser.database = additionalParameters.substring(0, ind);
urlParser.options = DefaultOptions.parse(urlParser.haMode, additionalParameters.substring(ind + 1), properties);
} else {
urlParser.database = additionalParameters;
urlParser.options = DefaultOptions.parse(urlParser.haMode, "", properties);
if (!"".equals(additionalParameters)) {
urlParser.database = additionalParameters;
}
urlParser.options = DefaultOptions.parse(urlParser.haMode, "", properties, urlParser.options);
}
}
setDefaultHostAddressType(urlParser);
Expand Down
32 changes: 20 additions & 12 deletions src/main/java/org/mariadb/jdbc/internal/util/DefaultOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,15 @@ public static Options parse(HaMode haMode, String urlParameters, Properties prop
return parse(haMode, urlParameters, properties, null);
}

private static Options parse(HaMode haMode, String urlParameters, Properties properties, Options options) {
/**
* Parse additional properties .
* @param haMode current haMode.
* @param urlParameters options defined in url
* @param properties options defined by properties
* @param options initial options
* @return options
*/
public static Options parse(HaMode haMode, String urlParameters, Properties properties, Options options) {
if (!"".equals(urlParameters)) {
String[] parameters = urlParameters.split("&");
for (String parameter : parameters) {
Expand All @@ -419,41 +427,41 @@ private static Options parse(HaMode haMode, Properties properties, Options optio
try {
for (DefaultOptions o : DefaultOptions.values()) {

String propertieValue = properties.getProperty(o.name);
if (propertieValue == null) {
String propertyValue = properties.getProperty(o.name);
if (propertyValue == null) {
if (o.name.equals("createDatabaseIfNotExist")) {
propertieValue = properties.getProperty("createDB");
propertyValue = properties.getProperty("createDB");
} else if (o.name.equals("useSsl")) {
propertieValue = properties.getProperty("useSSL");
propertyValue = properties.getProperty("useSSL");
}
}

if (propertieValue != null) {
if (propertyValue != null) {
if (o.objType.equals(String.class)) {
Options.class.getField(o.name).set(options, propertieValue);
Options.class.getField(o.name).set(options, propertyValue);
} else if (o.objType.equals(Boolean.class)) {
String value = propertieValue.toLowerCase();
String value = propertyValue.toLowerCase();
if ("1".equals(value)) {
value = "true";
} else if ("0".equals(value)) {
value = "false";
}
if (!"true".equals(value) && !"false".equals(value)) {
throw new IllegalArgumentException("Optional parameter " + o.name + " must be boolean (true/false or 0/1) was \""
+ propertieValue + "\"");
+ propertyValue + "\"");
}
Options.class.getField(o.name).set(options, Boolean.valueOf(value));
} else if (o.objType.equals(Integer.class)) {
try {
Integer value = Integer.parseInt(propertieValue);
Integer value = Integer.parseInt(propertyValue);
if (value.compareTo((Integer) o.minValue) < 0 || value.compareTo((Integer) o.maxValue) > 0) {
throw new IllegalArgumentException("Optional parameter " + o.name + " must be greater or equal to " + o.minValue
+ ((((Integer) o.maxValue).intValue() != Integer.MAX_VALUE) ? " and smaller than " + o.maxValue : " ")
+ ", was \"" + propertieValue + "\"");
+ ", was \"" + propertyValue + "\"");
}
Options.class.getField(o.name).set(options, value);
} catch (NumberFormatException n) {
throw new IllegalArgumentException("Optional parameter " + o.name + " must be Integer, was \"" + propertieValue + "\"");
throw new IllegalArgumentException("Optional parameter " + o.name + " must be Integer, was \"" + propertyValue + "\"");
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.mariadb.jdbc.internal.util.constant;

public final class Version {
public static final String version = "1.3.1";
public static final String version = "1.3.2-SNAPSHOT";
public static final int majorVersion = 1;
public static final int minorVersion = 3;
public static final int patchVersion = 1;
public static final String qualifier = "";
public static final int patchVersion = 2;
public static final String qualifier = "SNAPSHOT";

}

0 comments on commit da75bf7

Please sign in to comment.