You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2014/02/26 20:41:27 UTC
svn commit: r1572216 - in /commons/proper/dbcp/trunk:
findbugs-exclude-filter.xml
src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
Author: markt
Date: Wed Feb 26 19:41:27 2014
New Revision: 1572216
URL: http://svn.apache.org/r1572216
Log:
Findbugs fixes
Modified:
commons/proper/dbcp/trunk/findbugs-exclude-filter.xml
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
Modified: commons/proper/dbcp/trunk/findbugs-exclude-filter.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/findbugs-exclude-filter.xml?rev=1572216&r1=1572215&r2=1572216&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/findbugs-exclude-filter.xml (original)
+++ commons/proper/dbcp/trunk/findbugs-exclude-filter.xml Wed Feb 26 19:41:27 2014
@@ -28,4 +28,10 @@
<Class name="~.*\.Tester.*"/>
<Bug pattern="NP_NONNULL_RETURN_VIOLATION" />
</Match>
+ <!-- Not worth coding around for test code -->
+ <Match>
+ <Class name="org.apache.commons.dbcp2.TesterResultSet"/>
+ <Method name="<init>"/>
+ <Bug pattern="EI_EXPOSE_REP2"/>
+ </Match>
</FindBugsFilter>
Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java?rev=1572216&r1=1572215&r2=1572216&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java (original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java Wed Feb 26 19:41:27 2014
@@ -80,7 +80,7 @@ public class TesterPreparedStatement ext
if("null".equals(sql)) {
return null;
} else {
- return new TesterResultSet(this, null, _resultSetType, _resultSetConcurrency);
+ return new TesterResultSet(this, _resultSetType, _resultSetConcurrency);
}
}
@@ -99,7 +99,7 @@ public class TesterPreparedStatement ext
// Simulate timeout if queryTimout is set to less than 5 seconds
throw new SQLException("query timeout");
} else {
- return new TesterResultSet(this, null, _resultSetType, _resultSetConcurrency);
+ return new TesterResultSet(this, _resultSetType, _resultSetConcurrency);
}
}
@@ -285,7 +285,7 @@ public class TesterPreparedStatement ext
@Override
public ResultSet getGeneratedKeys() throws SQLException {
- return new TesterResultSet(this, null, _resultSetType, _resultSetConcurrency);
+ return new TesterResultSet(this, _resultSetType, _resultSetConcurrency);
}
@Override
Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java?rev=1572216&r1=1572215&r2=1572216&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java (original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java Wed Feb 26 19:41:27 2014
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,13 +31,14 @@ import java.util.Calendar;
import java.util.Map;
import java.io.InputStream;
import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import java.sql.NClob;
import java.sql.RowId;
import java.sql.SQLXML;
/**
* A dummy {@link ResultSet}, for testing purposes.
- *
+ *
* @author Rodney Waldhoff
* @author Dirk Verbeeck
* @version $Revision$ $Date$
@@ -52,19 +53,19 @@ public class TesterResultSet implements
_data = data;
}
- public TesterResultSet(Statement stmt, Object[][] data, int type, int concurrency) {
+ public TesterResultSet(Statement stmt, int type, int concurrency) {
_statement = stmt;
- _data = data;
+ _data = null;
_type = type;
_concurrency = concurrency;
}
-
+
protected int _type = ResultSet.TYPE_FORWARD_ONLY;
protected int _concurrency = ResultSet.CONCUR_READ_ONLY;
protected Object[][] _data = null;
protected int _currentRow = -1;
-
+
protected Statement _statement = null;
protected int _rowsLeft = 2;
protected boolean _open = true;
@@ -90,12 +91,12 @@ public class TesterResultSet implements
if (!_open) {
return;
}
-
+
// Not all result sets are generated from statements eg DatabaseMetaData
if (_statement != null) {
((TesterStatement)_statement)._resultSet = null;
}
-
+
_open = false;
}
@@ -270,7 +271,12 @@ public class TesterResultSet implements
@Override
public byte[] getBytes(String columnName) throws SQLException {
checkOpen();
- return columnName.getBytes();
+ try {
+ return columnName.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ // Impossible. JVMs are required to support UTF-8
+ return null;
+ }
}
@Override