Skip to content

Commit

Permalink
Clean up unnecessary constructor parameters, mark as internal API
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotteveel committed Apr 13, 2024
1 parent c178185 commit e20c9b1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
5 changes: 4 additions & 1 deletion src/docs/asciidoc/release_notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,10 @@ When in doubt, use `false` to communicate that no such synchronization is requir
** `skipFully` was removed, use standard Java `InputStream.skipNBytes` instead
** `readShort` was removed as it was unused
* The no-arg constructor of `FBXAException` was removed
* `FBResultSet.close(boolean)` was removed;
* `FBResultSet`
** The constructors are now all marked as internal API, as they effectively already were due to arguments of internal API classes
** The constructor `FBResultSet(FBConnection, FBStatement, FbStatement, FBObjectListener.ResultSetListener, boolean, int, int, int, boolean)` was replaced by `FBResultSet(FBStatement, FBObjectListener.ResultSetListener, boolean, int, int, int)`
** `close(boolean)` was removed;
use `close(boolean, CompletionReason)`
* `UnixCrypt` was replaced by `LegacyHash`, which only performs the password hash specific to Firebird legacy authentication
* `GDSFactoryPlugin.getDatabasePath(String, Integer, String)` and `getDatabasePath(String)` no longer throw `GDSException`, but instead throw `SQLException`
Expand Down
36 changes: 15 additions & 21 deletions src/main/org/firebirdsql/jdbc/FBResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.firebirdsql.jdbc.field.FBField;
import org.firebirdsql.jdbc.field.FieldDataProvider;
import org.firebirdsql.jdbc.field.TrimmableField;
import org.firebirdsql.util.InternalApi;

import java.io.InputStream;
import java.io.Reader;
Expand Down Expand Up @@ -109,36 +110,25 @@ public void rowChanged(FBFetcher fetcher, RowValue newRow) throws SQLException {
* Creates a new {@code FBResultSet} instance.
*/
@SuppressWarnings("java:S1141")
public FBResultSet(FBConnection connection,
FBStatement fbStatement,
FbStatement stmt,
FBObjectListener.ResultSetListener listener,
boolean metaDataQuery,
int rsType,
int rsConcurrency,
int rsHoldability,
boolean cached)
throws SQLException {
@InternalApi
public FBResultSet(FBStatement fbStatement, FBObjectListener.ResultSetListener listener, boolean metaDataQuery,
int rsType, int rsConcurrency, int rsHoldability) throws SQLException {
assert rsType != ResultSet.TYPE_SCROLL_SENSITIVE : "Received unsupported rsType == TYPE_SCROLL_SENSITIVE";
this.fbStatement = fbStatement;
FbStatement stmt = fbStatement.getStatementHandle();
try {
this.connection = connection;
this.connection = (FBConnection) fbStatement.getConnection();
this.gdsHelper = connection != null ? connection.getGDSHelper() : null;
cursorName = fbStatement.getCursorName();
this.listener = listener != null ? listener : FBObjectListener.NoActionResultSetListener.instance();
rowDescriptor = stmt.getRowDescriptor();
fields = new FBField[rowDescriptor.getCount()];
colNames = new HashMap<>(rowDescriptor.getCount(), 1);
this.fbStatement = fbStatement;

if (rsType == ResultSet.TYPE_SCROLL_SENSITIVE) {
fbStatement.addWarning(FbExceptionBuilder
.forWarning(JaybirdErrorCodes.jb_resultSetTypeDowngradeReasonScrollSensitive)
.toSQLException(SQLWarning.class));
rsType = ResultSet.TYPE_SCROLL_INSENSITIVE;
}
boolean serverSideScrollable = rsHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT && !metaDataQuery
&& connection != null && connection.isScrollableCursor(PropertyConstants.SCROLLABLE_CURSOR_SERVER)
&& stmt.supportsFetchScroll();
cached = cached || metaDataQuery || !(rsType == TYPE_FORWARD_ONLY || serverSideScrollable);
boolean cached = metaDataQuery || !(rsType == TYPE_FORWARD_ONLY || serverSideScrollable);

prepareVars(cached, metaDataQuery);
if (cached) {
Expand All @@ -157,7 +147,7 @@ public FBResultSet(FBConnection connection,
if (rsConcurrency == ResultSet.CONCUR_UPDATABLE) {
try {
rowUpdater = new FBRowUpdater(connection, rowDescriptor, cached, listener);
if (serverSideScrollable && fbFetcher instanceof FBServerScrollFetcher) {
if (fbFetcher instanceof FBServerScrollFetcher) {
fbFetcher = new FBUpdatableFetcher(fbFetcher, this, rowDescriptor.createDeletedRowMarker());
}
} catch (FBResultSetNotUpdatableException ex) {
Expand All @@ -170,7 +160,7 @@ public FBResultSet(FBConnection connection,
this.rsType = rsType;
this.rsConcurrency = rsConcurrency;
this.rsHoldability = rsHoldability;
this.fetchDirection = fbStatement.getFetchDirection();
fetchDirection = fbStatement.getFetchDirection();
} catch (SQLException e) {
try {
// Ensure cursor is closed to avoid problems with statement reuse
Expand Down Expand Up @@ -198,6 +188,7 @@ public FBResultSet(FBConnection connection,
* @param listener
* result set listener
*/
@InternalApi
public FBResultSet(RowDescriptor rowDescriptor, List<RowValue> rows, FBObjectListener.ResultSetListener listener)
throws SQLException {
this(rowDescriptor, null, rows, listener, false, false);
Expand All @@ -217,6 +208,7 @@ public FBResultSet(RowDescriptor rowDescriptor, List<RowValue> rows, FBObjectLis
* @param rows
* row data
*/
@InternalApi
public FBResultSet(RowDescriptor rowDescriptor, List<RowValue> rows) throws SQLException {
this(rowDescriptor, rows, null);
}
Expand All @@ -239,6 +231,7 @@ public FBResultSet(RowDescriptor rowDescriptor, List<RowValue> rows) throws SQLE
* @param retrieveBlobs
* {@code true} retrieves the blob data
*/
@InternalApi
public FBResultSet(RowDescriptor rowDescriptor, FBConnection connection, List<RowValue> rows,
boolean retrieveBlobs) throws SQLException {
this(rowDescriptor, connection, rows, null, retrieveBlobs, true);
Expand All @@ -264,6 +257,7 @@ public FBResultSet(RowDescriptor rowDescriptor, FBConnection connection, List<Ro
* {@code true} when strings need to be trimmed (generally only for metadata queries)
* @since 5.0.1
*/
@InternalApi
public FBResultSet(RowDescriptor rowDescriptor, FBConnection connection, List<RowValue> rows,
FBObjectListener.ResultSetListener listener, boolean retrieveBlobs, boolean trimStrings)
throws SQLException {
Expand Down
22 changes: 19 additions & 3 deletions src/main/org/firebirdsql/jdbc/FBStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* @author David Jencks
* @author Mark Rotteveel
*/
@SuppressWarnings("RedundantThrows")
@SuppressWarnings({ "RedundantThrows", "SqlSourceToSinkFlow" })
public class FBStatement implements FirebirdStatement {

private static final System.Logger log = System.getLogger(FBStatement.class.getName());
Expand Down Expand Up @@ -168,6 +168,11 @@ public void executionStarted(FirebirdRowUpdater updater) throws SQLException {
}

protected FBStatement(GDSHelper c, int rsType, int rsConcurrency, int rsHoldability, FBObjectListener.StatementListener statementListener) throws SQLException {
if (rsType == ResultSet.TYPE_SCROLL_SENSITIVE) {
throw new FBDriverNotCapableException(
"Received TYPE_SCROLL_SENSITIVE, but Jaybird does not support this type. This is likely "
+ "an implementation bug, so please report this.");
}
this.gdsHelper = c;

this.rsConcurrency = rsConcurrency;
Expand Down Expand Up @@ -604,8 +609,8 @@ public ResultSet getResultSet(boolean metaDataQuery) throws SQLException {
if (cursorName != null) {
fbStatement.setCursorName(cursorName);
}
return currentRs = new FBResultSet(connection, this, fbStatement, resultSetListener, metaDataQuery,
rsType, rsConcurrency, rsHoldability, false);
return currentRs = new FBResultSet(this, resultSetListener, metaDataQuery,
rsType, rsConcurrency, rsHoldability);
} else if (!specialResult.isEmpty()) {
return currentRs = createSpecialResultSet(resultSetListener);
}
Expand Down Expand Up @@ -848,6 +853,17 @@ public Connection getConnection() throws SQLException {
return connection;
}

/**
* @return Instance of {@link FbStatement} associated with this statement. Can be {@code null} if no statement has
* been executed yet.
* @throws SQLException
* if this statement is closed
*/
final FbStatement getStatementHandle() throws SQLException {
checkValidity();
return fbStatement;
}

void closeResultSet(boolean notifyListener) throws SQLException {
closeResultSet(notifyListener, CompletionReason.OTHER);
}
Expand Down

0 comments on commit e20c9b1

Please sign in to comment.