Skip to content

Commit

Permalink
Replace FBProcedureCall.clone() with static copyOf
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotteveel committed Sep 27, 2024
1 parent 71a0051 commit ddb7ffb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/docs/asciidoc/release_notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,8 @@ use standard Java `InputStream.skipNBytes` instead
* `FBResultSet`
** `close(boolean)` was removed;
use `close(boolean, CompletionReason)`
* `FBProcedureCall` is no longer cloneable;
use `FBProcedureCall.copyOf(FBProcedureCall)`
* `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`
* `GDSFactory.getDatabasePath(...)` no longer throw `GDSException`, but instead throw `SQLException`
Expand Down
2 changes: 1 addition & 1 deletion src/main/org/firebirdsql/jdbc/FBCallableStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void addBatch() throws SQLException {
try (LockCloseable ignored = withLock()) {
checkValidity();
procedureCall.checkParameters();
batchList.add((FBProcedureCall) procedureCall.clone());
batchList.add(FBProcedureCall.copyOf(procedureCall));
}
}

Expand Down
30 changes: 14 additions & 16 deletions src/main/org/firebirdsql/jdbc/FBProcedureCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,26 @@
*/
@InternalApi
@NullMarked
public class FBProcedureCall implements Cloneable {
public class FBProcedureCall {

private static final String NATIVE_CALL_COMMAND = "EXECUTE PROCEDURE ";
private static final String NATIVE_SELECT_COMMAND = "SELECT * FROM ";

// TODO Replace with a copy constructor
public Object clone() {
try {
FBProcedureCall newProcedureCall = (FBProcedureCall) super.clone();
private @Nullable String name;
private List<@Nullable FBProcedureParam> inputParams = new ArrayList<>();
private List<@Nullable FBProcedureParam> outputParams = new ArrayList<>();

//Copy each input and output parameter.
newProcedureCall.inputParams = cloneParameters(inputParams);
newProcedureCall.outputParams = cloneParameters(outputParams);
public FBProcedureCall() {
}

return newProcedureCall;
} catch (CloneNotSupportedException e) {
throw new AssertionError("clone() unexpectedly not supported", e);
}
private FBProcedureCall(FBProcedureCall source) {
name = source.name;
inputParams = cloneParameters(source.inputParams);
outputParams = cloneParameters(source.outputParams);
}

public static FBProcedureCall copyOf(FBProcedureCall source) {
return new FBProcedureCall(source);
}

private static List<@Nullable FBProcedureParam> cloneParameters(final List<@Nullable FBProcedureParam> parameters) {
Expand All @@ -67,10 +69,6 @@ public Object clone() {
return clonedParameters;
}

private @Nullable String name;
private List<@Nullable FBProcedureParam> inputParams = new ArrayList<>();
private List<@Nullable FBProcedureParam> outputParams = new ArrayList<>();

/**
* Get the name of the procedure to be called.
*
Expand Down

0 comments on commit ddb7ffb

Please sign in to comment.