Skip to content
Permalink
Browse files

[misc] uniform code style format

  • Loading branch information
rusher committed Nov 22, 2019
1 parent f7c59bc commit 1cdeac5262ec78de2a26e5cc4a0dc7ffa73b6d01
Showing with 954 additions and 1,711 deletions.
  1. +1 −1 .travis.yml
  2. +13 −13 build.xml
  3. +0 −1 maven-build.properties
  4. +275 −259 maven-build.xml
  5. +38 −37 src/main/java/org/mariadb/jdbc/MariaDbConnection.java
  6. +2 −2 src/main/java/org/mariadb/jdbc/MariaDbStatement.java
  7. +2 −1 src/main/java/org/mariadb/jdbc/authentication/AuthenticationPluginLoader.java
  8. +0 −1 src/main/java/org/mariadb/jdbc/internal/com/read/dao/CmdInformationSingle.java
  9. +5 −2 src/main/java/org/mariadb/jdbc/internal/com/send/authentication/SendPamAuthPacket.java
  10. +9 −15 src/main/java/org/mariadb/jdbc/internal/osgi/MariaDbActivator.java
  11. +20 −5 src/main/java/org/mariadb/jdbc/internal/osgi/MariaDbDataSourceFactory.java
  12. +1 −1 src/main/java/org/mariadb/jdbc/internal/util/constant/Version.java
  13. +1 −1 src/main/resources/Version.java.template
  14. +4 −10 src/test/java/org/mariadb/jdbc/AllowMultiQueriesTest.java
  15. +2 −8 src/test/java/org/mariadb/jdbc/AutoReconnectTest.java
  16. +19 −42 src/test/java/org/mariadb/jdbc/BaseTest.java
  17. +5 −15 src/test/java/org/mariadb/jdbc/BasicBatchTest.java
  18. +4 −7 src/test/java/org/mariadb/jdbc/BasicFailover.java
  19. +8 −21 src/test/java/org/mariadb/jdbc/BigQueryTest.java
  20. +8 −33 src/test/java/org/mariadb/jdbc/BlobTest.java
  21. +4 −11 src/test/java/org/mariadb/jdbc/BooleanTest.java
  22. +4 −11 src/test/java/org/mariadb/jdbc/BufferTest.java
  23. +3 −3 src/test/java/org/mariadb/jdbc/ByteTest.java
  24. +4 −15 src/test/java/org/mariadb/jdbc/CallStatementTest.java
  25. +7 −19 src/test/java/org/mariadb/jdbc/CancelTest.java
  26. +4 −4 src/test/java/org/mariadb/jdbc/CatalogTest.java
  27. +5 −10 src/test/java/org/mariadb/jdbc/CheckDataTest.java
  28. +4 −9 src/test/java/org/mariadb/jdbc/ClientPreparedStatementParsingTest.java
  29. +5 −14 src/test/java/org/mariadb/jdbc/ClientPreparedStatementTest.java
  30. +8 −19 src/test/java/org/mariadb/jdbc/CollationTest.java
  31. +1 −1 src/test/java/org/mariadb/jdbc/ComMultiPrepareStatementTest.java
  32. +5 −11 src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java
  33. +10 −33 src/test/java/org/mariadb/jdbc/ConnectionTest.java
  34. +3 −9 src/test/java/org/mariadb/jdbc/CredentialPluginTest.java
  35. +6 −12 src/test/java/org/mariadb/jdbc/DataNTypeTest.java
  36. +5 −10 src/test/java/org/mariadb/jdbc/DataSourcePoolTest.java
  37. +5 −11 src/test/java/org/mariadb/jdbc/DataSourceTest.java
  38. +6 −12 src/test/java/org/mariadb/jdbc/DataTypeSignedTest.java
  39. +6 −13 src/test/java/org/mariadb/jdbc/DataTypeUnsignedTest.java
  40. +5 −17 src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java
  41. +6 −22 src/test/java/org/mariadb/jdbc/DatatypeCompatibilityTest.java
  42. +9 −33 src/test/java/org/mariadb/jdbc/DatatypeTest.java
  43. +5 −20 src/test/java/org/mariadb/jdbc/DateTest.java
  44. +7 −15 src/test/java/org/mariadb/jdbc/DistributedTransactionTest.java
  45. +12 −41 src/test/java/org/mariadb/jdbc/DriverTest.java
  46. +7 −13 src/test/java/org/mariadb/jdbc/ErrorMessageTest.java
  47. +9 −10 src/test/java/org/mariadb/jdbc/ExecuteBatchTest.java
  48. +4 −11 src/test/java/org/mariadb/jdbc/FetchSizeTest.java
  49. +4 −11 src/test/java/org/mariadb/jdbc/GeneratedKeysTest.java
  50. +4 −8 src/test/java/org/mariadb/jdbc/GeneratedTest.java
  51. +5 −9 src/test/java/org/mariadb/jdbc/GeometryTest.java
  52. +5 −11 src/test/java/org/mariadb/jdbc/GiganticLoadDataInfileTest.java
  53. +7 −10 src/test/java/org/mariadb/jdbc/JdbcParserTest.java
  54. +4 −8 src/test/java/org/mariadb/jdbc/LocalInfileDisableTest.java
  55. +5 −20 src/test/java/org/mariadb/jdbc/LocalInfileInputStreamTest.java
  56. +6 −14 src/test/java/org/mariadb/jdbc/LocalTimeTest.java
  57. +6 −9 src/test/java/org/mariadb/jdbc/MariaDbBlobTest.java
  58. +7 −14 src/test/java/org/mariadb/jdbc/MariaDbClobTest.java
  59. +4 −10 src/test/java/org/mariadb/jdbc/MariaDbCompatibilityTest.java
  60. +4 −7 src/test/java/org/mariadb/jdbc/MariaDbDatabaseMetaDataTest.java
  61. +11 −26 src/test/java/org/mariadb/jdbc/MariaDbPoolDataSourceTest.java
  62. +2 −2 src/test/java/org/mariadb/jdbc/MariaXaResourceTest.java
  63. +12 −24 src/test/java/org/mariadb/jdbc/MultiTest.java
  64. +2 −5 src/test/java/org/mariadb/jdbc/MyEventListener.java
  65. +7 −15 src/test/java/org/mariadb/jdbc/ParserTest.java
  66. +6 −10 src/test/java/org/mariadb/jdbc/PasswordEncodingTest.java
  67. +5 −9 src/test/java/org/mariadb/jdbc/PooledConnectionTest.java
  68. +6 −18 src/test/java/org/mariadb/jdbc/PreparedStatementTest.java
  69. +5 −11 src/test/java/org/mariadb/jdbc/RePrepareTest.java
  70. +5 −9 src/test/java/org/mariadb/jdbc/ReconnectionStateMaxAllowedStatement.java
  71. +5 −13 src/test/java/org/mariadb/jdbc/ResultSetMetaDataTest.java
  72. +5 −19 src/test/java/org/mariadb/jdbc/ResultSetTest.java
  73. +3 −5 src/test/java/org/mariadb/jdbc/ResultSetUnsupportedMethodsTest.java
  74. +5 −10 src/test/java/org/mariadb/jdbc/ScalarFunctionsTest.java
  75. +4 −9 src/test/java/org/mariadb/jdbc/ScrollTypeTest.java
  76. +1 −1 src/test/java/org/mariadb/jdbc/SerializableClass.java
  77. +11 −35 src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java
  78. +9 −19 src/test/java/org/mariadb/jdbc/Sha256AuthenticationTest.java
  79. +15 −40 src/test/java/org/mariadb/jdbc/SslTest.java
  80. +4 −10 src/test/java/org/mariadb/jdbc/StateChangeTest.java
  81. +11 −26 src/test/java/org/mariadb/jdbc/StatementTest.java
  82. +9 −29 src/test/java/org/mariadb/jdbc/StoredProcedureTest.java
  83. +5 −12 src/test/java/org/mariadb/jdbc/TimeoutTest.java
  84. +8 −31 src/test/java/org/mariadb/jdbc/TimezoneDaylightSavingTimeTest.java
  85. +5 −13 src/test/java/org/mariadb/jdbc/TimezoneExplicitCalendarTest.java
  86. +4 −8 src/test/java/org/mariadb/jdbc/TransactionTest.java
  87. +4 −12 src/test/java/org/mariadb/jdbc/TruncateExceptionTest.java
  88. +4 −8 src/test/java/org/mariadb/jdbc/UnicodeTest.java
  89. +3 −6 src/test/java/org/mariadb/jdbc/UpdateResultSetMethodsTest.java
  90. +6 −16 src/test/java/org/mariadb/jdbc/UpdateResultSetTest.java
  91. +4 −6 src/test/java/org/mariadb/jdbc/UtilTest.java
  92. +6 −16 src/test/java/org/mariadb/jdbc/failover/AllowMasterDownTest.java
  93. +7 −9 src/test/java/org/mariadb/jdbc/failover/AuroraAutoDiscoveryTest.java
  94. +7 −18 src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java
  95. +6 −8 src/test/java/org/mariadb/jdbc/failover/BaseMonoServer.java
  96. +13 −27 src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java
  97. +7 −17 src/test/java/org/mariadb/jdbc/failover/BaseReplication.java
  98. +5 −12 src/test/java/org/mariadb/jdbc/failover/CancelTest.java
  99. +7 −18 src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java
  100. +5 −11 src/test/java/org/mariadb/jdbc/failover/LoadBalanceFailoverTest.java
  101. +7 −14 src/test/java/org/mariadb/jdbc/failover/MonoServerFailoverTest.java
  102. +4 −5 src/test/java/org/mariadb/jdbc/failover/OldFailoverTest.java
  103. +6 −14 src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java
  104. +11 −19 src/test/java/org/mariadb/jdbc/failover/SequentialFailoverTest.java
  105. +4 −5 src/test/java/org/mariadb/jdbc/failover/TcpProxy.java
  106. +6 −5 src/test/java/org/mariadb/jdbc/internal/com/read/resultset/ColumnInformationTest.java
  107. +7 −9 src/test/java/org/mariadb/jdbc/internal/protocol/tls/HostnameVerifierImplTest.java
  108. +10 −14 src/test/java/org/mariadb/jdbc/internal/util/DefaultOptionsTest.java
  109. +1 −1 src/test/java/org/mariadb/jdbc/internal/util/SchedulerServiceProviderHolderTest.java
  110. +3 −6 src/test/java/org/mariadb/jdbc/internal/util/UtilsTest.java
  111. +2 −3 src/test/java/org/mariadb/jdbc/internal/util/buffer/BufferTest.java
  112. +2 −3 src/test/java/org/mariadb/jdbc/internal/util/dao/ClientPrepareResultTest.java
  113. +5 −5 src/test/resources/style.xml
@@ -87,4 +87,4 @@ script:
- .travis/script.sh

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
@@ -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>
@@ -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

Large diffs are not rendered by default.

@@ -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
@@ -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
@@ -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
@@ -75,6 +75,8 @@
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");
@@ -88,8 +90,6 @@
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;
@@ -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);
}
@@ -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++) {
@@ -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);
}
@@ -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;
@@ -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
@@ -94,5 +89,4 @@ public void stop(BundleContext context) throws Exception {
SchedulerServiceProviderHolder.close();
}
}

}
@@ -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)) {
@@ -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)) {
@@ -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;
@@ -58,4 +58,4 @@
public static final int minorVersion = 5;
public static final int patchVersion = 2;
public static final String qualifier = "-SNAPSHOT";
}
}
@@ -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";
}
}
@@ -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 {

@@ -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 {

0 comments on commit 1cdeac5

Please sign in to comment.
You can’t perform that action at this time.