You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/08/21 21:16:16 UTC
[commons-dbcp] branch master updated: Fix formatting
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
The following commit(s) were added to refs/heads/master by this push:
new e63245ea Fix formatting
e63245ea is described below
commit e63245ea14909b646b998976985eb92689aec69f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Aug 21 17:16:12 2023 -0400
Fix formatting
---
.../apache/commons/dbcp2/TestConnectionPool.java | 10 +-
.../org/apache/commons/dbcp2/TesterConnection.java | 14 +--
.../commons/dbcp2/TesterPreparedStatement.java | 4 +-
.../org/apache/commons/dbcp2/TesterResultSet.java | 102 ++++++++-------------
.../org/apache/commons/dbcp2/TesterStatement.java | 12 +--
5 files changed, 60 insertions(+), 82 deletions(-)
diff --git a/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java b/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
index f58ce259..a34fe13c 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
@@ -947,20 +947,20 @@ public abstract class TestConnectionPool {
@Test
public void testThreaded() {
final TestThread[] threads = new TestThread[getMaxTotal()];
- for(int i=0;i<threads.length;i++) {
- threads[i] = new TestThread(50,50);
+ for (int i = 0; i < threads.length; i++) {
+ threads[i] = new TestThread(50, 50);
final Thread t = new Thread(threads[i]);
t.start();
}
- for(int i=0;i<threads.length;i++) {
- while(!threads[i].complete()) {
+ for (int i = 0; i < threads.length; i++) {
+ while (!threads[i].complete()) {
try {
Thread.sleep(100L);
} catch (final Exception e) {
// ignored
}
}
- if(threads[i] != null && threads[i].failed()) {
+ if (threads[i] != null && threads[i].failed()) {
fail("Thread failed: " + i);
}
}
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterConnection.java b/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
index d1a94185..07122766 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
@@ -68,15 +68,15 @@ public class TesterConnection extends AbandonedTrace implements Connection {
protected void checkFailure() throws SQLException {
if (failure != null) {
- if(failure instanceof SQLException) {
- throw (SQLException)failure;
+ if (failure instanceof SQLException) {
+ throw (SQLException) failure;
}
throw new SQLException("TesterConnection failure", failure);
}
}
protected void checkOpen() throws SQLException {
- if(!_open) {
+ if (!_open) {
throw new SQLException("Connection is closed.");
}
checkFailure();
@@ -282,11 +282,13 @@ public class TesterConnection extends AbandonedTrace implements Connection {
@Override
public PreparedStatement prepareStatement(final String sql) throws SQLException {
checkOpen();
- if("null".equals(sql)) {
+ if ("null".equals(sql)) {
return null;
- } if("invalid".equals(sql)) {
+ }
+ if ("invalid".equals(sql)) {
throw new SQLException("invalid query");
- } if ("broken".equals(sql)) {
+ }
+ if ("broken".equals(sql)) {
throw new SQLException("broken connection");
}
return new TesterPreparedStatement(this, sql);
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java b/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
index caaec8ba..0b7a2d05 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
@@ -186,7 +186,7 @@ public class TesterPreparedStatement extends TesterStatement implements Prepared
@Override
public ResultSet executeQuery() throws SQLException {
checkOpen();
- if("null".equals(_sql)) {
+ if ("null".equals(_sql)) {
return null;
}
if (_queryTimeout > 0 && _queryTimeout < 5) {
@@ -199,7 +199,7 @@ public class TesterPreparedStatement extends TesterStatement implements Prepared
@Override
public ResultSet executeQuery(final String sql) throws SQLException {
checkOpen();
- if("null".equals(sql)) {
+ if ("null".equals(sql)) {
return null;
}
return new TesterResultSet(this, _resultSetType, _resultSetConcurrency);
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java b/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
index c67b4d1f..dad25d59 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
@@ -54,19 +54,21 @@ public class TesterResultSet extends AbandonedTrace implements ResultSet {
public TesterResultSet(final Statement stmt) {
_statement = stmt;
}
+
public TesterResultSet(final Statement stmt, final int type, final int concurrency) {
_statement = stmt;
_data = null;
_type = type;
_concurrency = concurrency;
}
+
public TesterResultSet(final Statement stmt, final Object[][] data) {
_statement = stmt;
_data = data;
}
@Override
- public boolean absolute( final int row ) throws SQLException {
+ public boolean absolute(final int row) throws SQLException {
checkOpen();
return false;
}
@@ -87,7 +89,7 @@ public class TesterResultSet extends AbandonedTrace implements ResultSet {
}
protected void checkOpen() throws SQLException {
- if(!_open) {
+ if (!_open) {
throw new SQLException("ResultSet is closed.");
}
}
@@ -109,7 +111,7 @@ public class TesterResultSet extends AbandonedTrace implements ResultSet {
// Not all result sets are generated from statements eg DatabaseMetaData
if (_statement != null) {
- ((TesterStatement)_statement)._resultSet = null;
+ ((TesterStatement) _statement)._resultSet = null;
}
_open = false;
@@ -223,19 +225,19 @@ public class TesterResultSet extends AbandonedTrace implements ResultSet {
@Override
public byte getByte(final int columnIndex) throws SQLException {
checkOpen();
- return (byte)columnIndex;
+ return (byte) columnIndex;
}
@Override
public byte getByte(final String columnName) throws SQLException {
checkOpen();
- return (byte)columnName.hashCode();
+ return (byte) columnName.hashCode();
}
@Override
public byte[] getBytes(final int columnIndex) throws SQLException {
checkOpen();
- return new byte[] {(byte) columnIndex};
+ return new byte[] { (byte) columnIndex };
}
@Override
@@ -285,11 +287,11 @@ public class TesterResultSet extends AbandonedTrace implements ResultSet {
return null;
}
- @Override
-public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws SQLException {
- checkOpen();
- return null;
-}
+ @Override
+ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws SQLException {
+ checkOpen();
+ return null;
+ }
@Override
public java.sql.Date getDate(final String columnName) throws SQLException {
@@ -327,7 +329,6 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
return 2;
}
-
@Override
public float getFloat(final int columnIndex) throws SQLException {
checkOpen();
@@ -348,7 +349,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
@Override
public int getInt(final int columnIndex) throws SQLException {
checkOpen();
- return (short)columnIndex;
+ return (short) columnIndex;
}
@Override
@@ -409,7 +410,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
public Object getObject(final int columnIndex) throws SQLException {
checkOpen();
if (_data != null) {
- return _data[_currentRow][columnIndex-1];
+ return _data[_currentRow][columnIndex - 1];
}
return new Object();
}
@@ -420,7 +421,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public Object getObject(final int i, final Map<String,Class<?>> map) throws SQLException {
+ public Object getObject(final int i, final Map<String, Class<?>> map) throws SQLException {
checkOpen();
return new Object();
}
@@ -432,13 +433,12 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public <T> T getObject(final String columnLabel, final Class<T> type)
- throws SQLException {
+ public <T> T getObject(final String columnLabel, final Class<T> type) throws SQLException {
throw new SQLException("Not implemented.");
}
@Override
- public Object getObject(final String colName, final Map<String,Class<?>> map) throws SQLException {
+ public Object getObject(final String colName, final Map<String, Class<?>> map) throws SQLException {
checkOpen();
return colName;
}
@@ -474,13 +474,13 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
@Override
public short getShort(final int columnIndex) throws SQLException {
checkOpen();
- return (short)columnIndex;
+ return (short) columnIndex;
}
@Override
public short getShort(final String columnName) throws SQLException {
checkOpen();
- return (short)columnName.hashCode();
+ return (short) columnName.hashCode();
}
@Override
@@ -559,10 +559,8 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
return null;
}
-
@Override
- public java.sql.Timestamp getTimestamp(final String columnName, final Calendar cal)
- throws SQLException {
+ public java.sql.Timestamp getTimestamp(final String columnName, final Calendar cal) throws SQLException {
checkOpen();
return null;
}
@@ -600,9 +598,9 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
@Override
public SQLWarning getWarnings() throws SQLException {
- checkOpen();
- return null;
- }
+ checkOpen();
+ return null;
+ }
@Override
public void insertRow() throws SQLException {
@@ -685,7 +683,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public boolean relative( final int rows ) throws SQLException {
+ public boolean relative(final int rows) throws SQLException {
checkOpen();
return false;
}
@@ -728,14 +726,12 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateArray(final int columnIndex, final java.sql.Array x)
- throws SQLException {
+ public void updateArray(final int columnIndex, final java.sql.Array x) throws SQLException {
throw new SQLException("Not implemented.");
}
@Override
- public void updateArray(final String columnName, final java.sql.Array x)
- throws SQLException {
+ public void updateArray(final String columnName, final java.sql.Array x) throws SQLException {
throw new SQLException("Not implemented.");
}
@@ -744,16 +740,13 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
throw new SQLException("Not implemented.");
}
-
@Override
public void updateAsciiStream(final int columnIndex, final InputStream inputStream, final long length) throws SQLException {
throw new SQLException("Not implemented.");
}
@Override
- public void updateAsciiStream(final int columnIndex,
- final java.io.InputStream x,
- final int length) throws SQLException {
+ public void updateAsciiStream(final int columnIndex, final java.io.InputStream x, final int length) throws SQLException {
checkOpen();
}
@@ -768,9 +761,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateAsciiStream(final String columnName,
- final java.io.InputStream x,
- final int length) throws SQLException {
+ public void updateAsciiStream(final String columnName, final java.io.InputStream x, final int length) throws SQLException {
checkOpen();
}
@@ -795,9 +786,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateBinaryStream(final int columnIndex,
- final java.io.InputStream x,
- final int length) throws SQLException {
+ public void updateBinaryStream(final int columnIndex, final java.io.InputStream x, final int length) throws SQLException {
checkOpen();
}
@@ -812,9 +801,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateBinaryStream(final String columnName,
- final java.io.InputStream x,
- final int length) throws SQLException {
+ public void updateBinaryStream(final String columnName, final java.io.InputStream x, final int length) throws SQLException {
checkOpen();
}
@@ -829,8 +816,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateBlob(final int columnIndex, final java.sql.Blob x)
- throws SQLException {
+ public void updateBlob(final int columnIndex, final java.sql.Blob x) throws SQLException {
throw new SQLException("Not implemented.");
}
@@ -845,8 +831,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateBlob(final String columnName, final java.sql.Blob x)
- throws SQLException {
+ public void updateBlob(final String columnName, final java.sql.Blob x) throws SQLException {
throw new SQLException("Not implemented.");
}
@@ -881,9 +866,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateCharacterStream(final int columnIndex,
- final java.io.Reader x,
- final int length) throws SQLException {
+ public void updateCharacterStream(final int columnIndex, final java.io.Reader x, final int length) throws SQLException {
checkOpen();
}
@@ -892,16 +875,13 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
throw new SQLException("Not implemented.");
}
-
@Override
public void updateCharacterStream(final int columnIndex, final Reader reader, final long length) throws SQLException {
throw new SQLException("Not implemented.");
}
@Override
- public void updateCharacterStream(final String columnName,
- final java.io.Reader reader,
- final int length) throws SQLException {
+ public void updateCharacterStream(final String columnName, final java.io.Reader reader, final int length) throws SQLException {
checkOpen();
}
@@ -916,8 +896,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateClob(final int columnIndex, final java.sql.Clob x)
- throws SQLException {
+ public void updateClob(final int columnIndex, final java.sql.Clob x) throws SQLException {
throw new SQLException("Not implemented.");
}
@@ -932,8 +911,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateClob(final String columnName, final java.sql.Clob x)
- throws SQLException {
+ public void updateClob(final String columnName, final java.sql.Clob x) throws SQLException {
throw new SQLException("Not implemented.");
}
@@ -1103,8 +1081,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateObject(final String columnLabel, final Object x, final SQLType targetSqlType, final int scaleOrLength)
- throws SQLException {
+ public void updateObject(final String columnLabel, final Object x, final SQLType targetSqlType, final int scaleOrLength) throws SQLException {
checkOpen();
}
@@ -1179,8 +1156,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
}
@Override
- public void updateTimestamp(final String columnName, final java.sql.Timestamp x)
- throws SQLException {
+ public void updateTimestamp(final String columnName, final java.sql.Timestamp x) throws SQLException {
checkOpen();
}
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterStatement.java b/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
index e9238af3..987d8a8f 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
@@ -74,7 +74,7 @@ public class TesterStatement extends AbandonedTrace implements Statement {
}
protected void checkOpen() throws SQLException {
- if(!_open) {
+ if (!_open) {
throw new SQLException("Connection is closed.");
}
}
@@ -115,7 +115,7 @@ public class TesterStatement extends AbandonedTrace implements Statement {
@Override
public boolean execute(final String sql) throws SQLException {
checkOpen();
- if("invalid".equals(sql)) {
+ if ("invalid".equals(sql)) {
throw new SQLException("invalid query");
}
return _executeResponse;
@@ -175,18 +175,18 @@ public class TesterStatement extends AbandonedTrace implements Statement {
@Override
public ResultSet executeQuery(final String sql) throws SQLException {
checkOpen();
- if("null".equals(sql)) {
+ if ("null".equals(sql)) {
return null;
}
- if("invalid".equals(sql)) {
+ if ("invalid".equals(sql)) {
throw new SQLException("invalid query");
}
if ("broken".equals(sql)) {
throw new SQLException("broken connection");
}
- if("select username".equals(sql)) {
+ if ("select username".equals(sql)) {
final String userName = ((TesterConnection) _connection).getUserName();
- final Object[][] data = {{userName}};
+ final Object[][] data = { { userName } };
return new TesterResultSet(this, data);
}
// Simulate timeout if queryTimout is set to less than 5 seconds