Skip to content

Commit

Permalink
[misc] uniform code style format
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Nov 22, 2019
1 parent f7c59bc commit 1cdeac5
Show file tree
Hide file tree
Showing 113 changed files with 954 additions and 1,711 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ script:
- .travis/script.sh

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
26 changes: 13 additions & 13 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@
<!--suppress XmlUnboundNsPrefix -->
<project name="mariadb-java-client" default="package" basedir=".">

<!-- ====================================================================== -->
<!-- Import maven-build.xml into the current project -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- Import maven-build.xml into the current project -->
<!-- ====================================================================== -->

<import file="maven-build.xml"/>
<presetdef name="javac">
<javac includeantruntime="false"/>
</presetdef>
<!-- ====================================================================== -->
<!-- Help target -->
<!-- ====================================================================== -->
<import file="maven-build.xml"/>
<presetdef name="javac">
<javac includeantruntime="false"/>
</presetdef>
<!-- ====================================================================== -->
<!-- Help target -->
<!-- ====================================================================== -->

<target name="help">
<echo message="Please run: $ant -projecthelp"/>
</target>
<target name="help">
<echo message="Please run: $ant -projecthelp"/>
</target>

</project>
1 change: 0 additions & 1 deletion maven-build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
# OF SUCH DAMAGE.
# */
#

#Generated by Maven Ant Plugin - DO NOT EDIT THIS FILE!
#Mon Jul 13 22:05:03 CEST 2015
maven.settings.offline=false
Expand Down
534 changes: 275 additions & 259 deletions maven-build.xml

Large diffs are not rendered by default.

75 changes: 38 additions & 37 deletions src/main/java/org/mariadb/jdbc/MariaDbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,42 @@ public void setClientInfo(final String name, final String value) throws SQLClien
}
}

/**
* Returns a list containing the name and current value of each client info property supported by
* the driver. The value of a client info property may be null if the property has not been set
* and does not have a default value.
*
* @return A <code>Properties</code> object that contains the name and current value of each of
* the client info properties supported by the driver.
* @throws SQLException if the database server returns an error when fetching the client info
* values from the database or this method is called on a closed connection
*/
public Properties getClientInfo() throws SQLException {
checkConnection();
Properties properties = new Properties();
try (Statement statement = createStatement()) {
try (ResultSet rs =
statement.executeQuery("SELECT @ApplicationName, @ClientUser, @ClientHostname")) {
if (rs.next()) {
if (rs.getString(1) != null) {
properties.setProperty("ApplicationName", rs.getString(1));
}
if (rs.getString(2) != null) {
properties.setProperty("ClientUser", rs.getString(2));
}
if (rs.getString(3) != null) {
properties.setProperty("ClientHostname", rs.getString(3));
}
return properties;
}
}
}
properties.setProperty("ApplicationName", null);
properties.setProperty("ClientUser", null);
properties.setProperty("ClientHostname", null);
return properties;
}

/**
* Sets the value of the connection's client info properties. The <code>Properties</code> object
* contains the names and values of the client info properties to be set. The set of client info
Expand Down Expand Up @@ -1349,42 +1385,6 @@ public void setClientInfo(final Properties properties) throws SQLClientInfoExcep
}
}

/**
* Returns a list containing the name and current value of each client info property supported by
* the driver. The value of a client info property may be null if the property has not been set
* and does not have a default value.
*
* @return A <code>Properties</code> object that contains the name and current value of each of
* the client info properties supported by the driver.
* @throws SQLException if the database server returns an error when fetching the client info
* values from the database or this method is called on a closed connection
*/
public Properties getClientInfo() throws SQLException {
checkConnection();
Properties properties = new Properties();
try (Statement statement = createStatement()) {
try (ResultSet rs =
statement.executeQuery("SELECT @ApplicationName, @ClientUser, @ClientHostname")) {
if (rs.next()) {
if (rs.getString(1) != null) {
properties.setProperty("ApplicationName", rs.getString(1));
}
if (rs.getString(2) != null) {
properties.setProperty("ClientUser", rs.getString(2));
}
if (rs.getString(3) != null) {
properties.setProperty("ClientHostname", rs.getString(3));
}
return properties;
}
}
}
properties.setProperty("ApplicationName", null);
properties.setProperty("ClientUser", null);
properties.setProperty("ClientHostname", null);
return properties;
}

/**
* Returns the value of the client info property specified by name. This method may return null if
* the specified client info property has not been set and does not have a default value. This
Expand Down Expand Up @@ -1664,7 +1664,8 @@ public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
*/
public void reset() throws SQLException {
// COM_RESET_CONNECTION exist since mysql 5.7.3 and mariadb 10.2.4
// but not possible to use it with mysql waiting for https://bugs.mysql.com/bug.php?id=97633 correction.
// but not possible to use it with mysql waiting for https://bugs.mysql.com/bug.php?id=97633
// correction.
// and mariadb only since https://jira.mariadb.org/browse/MDEV-18281
boolean useComReset =
options.useResetConnection
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/mariadb/jdbc/MariaDbStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class MariaDbStatement implements Statement, Cloneable {
Pattern.compile("[0-9a-zA-Z\\$_\\u0080-\\uFFFF]*", Pattern.UNICODE_CASE | Pattern.CANON_EQ);
private static final Pattern escapePattern = Pattern.compile("[\u0000'\"\b\n\r\t\u001A\\\\]");
private static final Map<String, String> mapper = new HashMap<>();
// timeout scheduler
private static final Logger logger = LoggerFactory.getLogger(MariaDbStatement.class);

static {
mapper.put("\u0000", "\\0");
Expand All @@ -88,8 +90,6 @@ public class MariaDbStatement implements Statement, Cloneable {
mapper.put("\\", "\\\\");
}

// timeout scheduler
private static final Logger logger = LoggerFactory.getLogger(MariaDbStatement.class);
protected final ReentrantLock lock;
protected final int resultSetScrollType;
protected final int resultSetConcurrency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public static AuthenticationPlugin get(String type) throws SQLException {
throw new SQLException(
"Client does not support authentication protocol requested by server. "
+ "plugin type was = '"
+ type + "'",
+ type
+ "'",
"08004",
1251);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public ResultSet getGeneratedKeys(Protocol protocol, String sql) {
if (insertId == 0) {
return SelectResultSet.createEmptyResultSet();
}
//to be removed in 2.5.0. cannot in 2.4.x
if (updateCount > 1 && sql != null && !isDuplicateKeyUpdate(sql)) {
long[] insertIds = new long[(int) updateCount];
for (int i = 0; i < updateCount; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ public Buffer process(PacketOutputStream out, PacketInputStream in, AtomicIntege
password = authenticationData;
} else {
if (!options.nonMappedOptions.containsKey("password" + counter)) {
throw new SQLException("PAM authentication request multiple passwords, but "
+ "'password" + counter + "' is not set");
throw new SQLException(
"PAM authentication request multiple passwords, but "
+ "'password"
+ counter
+ "' is not set");
}
password = (String) options.nonMappedOptions.get("password" + counter);
}
Expand Down
24 changes: 9 additions & 15 deletions src/main/java/org/mariadb/jdbc/internal/osgi/MariaDbActivator.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,17 @@

package org.mariadb.jdbc.internal.osgi;

import java.sql.*;
import java.util.Dictionary;
import java.util.Hashtable;

import org.mariadb.jdbc.Driver;
import org.mariadb.jdbc.MariaDbDatabaseMetaData;
import org.mariadb.jdbc.*;
import org.mariadb.jdbc.internal.util.constant.Version;
import org.mariadb.jdbc.internal.util.scheduler.*;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.*;
import org.osgi.service.jdbc.*;

/**
* The MariaDbActivator registers the JDBC Service with the OSGi-Framework.
*
*/
import java.sql.*;
import java.util.*;

/** The MariaDbActivator registers the JDBC Service with the OSGi-Framework. */
public class MariaDbActivator implements BundleActivator {

private ServiceRegistration<DataSourceFactory> service;
Expand All @@ -78,8 +72,9 @@ public void start(BundleContext context) throws Exception {
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, Driver.class.getName());
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, MariaDbDatabaseMetaData.DRIVER_NAME);
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION, Version.version);
service = context.registerService(DataSourceFactory.class, new MariaDbDataSourceFactory(),
properties);
service =
context.registerService(
DataSourceFactory.class, new MariaDbDataSourceFactory(), properties);
}

@Override
Expand All @@ -94,5 +89,4 @@ public void stop(BundleContext context) throws Exception {
SchedulerServiceProviderHolder.close();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ private MariaDbDataSource createBasicDataSource(Properties props) throws SQLExce
try {
dataSource.setPortNumber(Integer.parseInt(props.getProperty(JDBC_PORT_NUMBER)));
} catch (NumberFormatException nfe) {
throw new SQLException("Port format must be integer, but value is '" + props.getProperty(JDBC_PORT_NUMBER) + "'");
throw new SQLException(
"Port format must be integer, but value is '"
+ props.getProperty(JDBC_PORT_NUMBER)
+ "'");
}
}
if (props.containsKey(JDBC_USER)) {
Expand All @@ -143,7 +146,10 @@ private MariaDbPoolDataSource createPoolDataSource(Properties props) throws SQLE
try {
dataSource.setPortNumber(Integer.parseInt(props.getProperty(JDBC_PORT_NUMBER)));
} catch (NumberFormatException nfe) {
throw new SQLException("Port number format must be integer, but value is '" + props.getProperty(JDBC_PORT_NUMBER) + "'");
throw new SQLException(
"Port number format must be integer, but value is '"
+ props.getProperty(JDBC_PORT_NUMBER)
+ "'");
}
}
if (props.containsKey(JDBC_USER)) {
Expand All @@ -159,21 +165,30 @@ private MariaDbPoolDataSource createPoolDataSource(Properties props) throws SQLE
try {
dataSource.setMaxIdleTime(Integer.parseInt(props.getProperty(JDBC_MAX_IDLE_TIME)));
} catch (NumberFormatException nfe) {
throw new SQLException("Max idle time format must be integer, but value is '" + props.getProperty(JDBC_MAX_IDLE_TIME) + "'");
throw new SQLException(
"Max idle time format must be integer, but value is '"
+ props.getProperty(JDBC_MAX_IDLE_TIME)
+ "'");
}
}
if (props.containsKey(JDBC_MAX_POOL_SIZE)) {
try {
dataSource.setMaxPoolSize(Integer.parseInt(props.getProperty(JDBC_MAX_POOL_SIZE)));
} catch (NumberFormatException nfe) {
throw new SQLException("Max pool size format must be integer, but value is '" + props.getProperty(JDBC_MAX_POOL_SIZE) + "'");
throw new SQLException(
"Max pool size format must be integer, but value is '"
+ props.getProperty(JDBC_MAX_POOL_SIZE)
+ "'");
}
}
if (props.containsKey(JDBC_MIN_POOL_SIZE)) {
try {
dataSource.setMinPoolSize(Integer.parseInt(props.getProperty(JDBC_MIN_POOL_SIZE)));
} catch (NumberFormatException nfe) {
throw new SQLException("Min pool size format must be integer, but value is '" + props.getProperty(JDBC_MIN_POOL_SIZE) + "'");
throw new SQLException(
"Min pool size format must be integer, but value is '"
+ props.getProperty(JDBC_MIN_POOL_SIZE)
+ "'");
}
}
return dataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ public final class Version {
public static final int minorVersion = 5;
public static final int patchVersion = 2;
public static final String qualifier = "-SNAPSHOT";
}
}
2 changes: 1 addition & 1 deletion src/main/resources/Version.java.template
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ public final class Version {
public static final int minorVersion = @minorVersion;
public static final int patchVersion = @patchVersion;
public static final String qualifier = "@qualifier";
}
}
14 changes: 4 additions & 10 deletions src/test/java/org/mariadb/jdbc/AllowMultiQueriesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@

package org.mariadb.jdbc;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.*;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.BeforeClass;
import org.junit.Test;
import java.sql.*;

import static org.junit.Assert.*;

public class AllowMultiQueriesTest extends BaseTest {

Expand Down
10 changes: 2 additions & 8 deletions src/test/java/org/mariadb/jdbc/AutoReconnectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@

package org.mariadb.jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLNonTransientConnectionException;
import java.sql.SQLTransientConnectionException;
import java.sql.Statement;
import org.junit.*;

import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import java.sql.*;

public class AutoReconnectTest extends BaseTest {

Expand Down
Loading

0 comments on commit 1cdeac5

Please sign in to comment.