Skip to content

Commit

Permalink
Clean Up - 'compatibleWithPreviousVersion' for 'getMetaData()' and 'g…
Browse files Browse the repository at this point in the history
…etClientInfo()' (#184)

Co-authored-by: Hannah Chan <[email protected]>
  • Loading branch information
hannahchan and Hannah Chan authored Sep 27, 2023
1 parent 988eb0e commit 096dcc0
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions src/main/java/com/atlassian/db/replica/api/DualConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ public boolean isClosed() {
@Override
public DatabaseMetaData getMetaData() throws SQLException {
checkClosed();
if (compatibleWithPreviousVersion) {
return connectionProvider.getWriteConnection(new RouteDecisionBuilder(Reason.RW_API_CALL)).getMetaData();
} else {
return connectionProvider.getReadConnection(new RouteDecisionBuilder(Reason.RO_API_CALL)).getMetaData();
}
return connectionProvider.getReadConnection(new RouteDecisionBuilder(Reason.RO_API_CALL)).getMetaData();
}

@Override
Expand Down Expand Up @@ -545,29 +541,17 @@ public void setClientInfo(Properties properties) throws SQLClientInfoException {
@Override
public String getClientInfo(String name) throws SQLException {
checkClosed();
if (compatibleWithPreviousVersion) {
return connectionProvider
.getWriteConnection(new RouteDecisionBuilder(Reason.RW_API_CALL))
.getClientInfo(name);
} else {
return connectionProvider
.getReadConnection(new RouteDecisionBuilder(Reason.RO_API_CALL))
.getClientInfo(name);
}
return connectionProvider
.getReadConnection(new RouteDecisionBuilder(Reason.RO_API_CALL))
.getClientInfo(name);
}

@Override
public Properties getClientInfo() throws SQLException {
checkClosed();
if (compatibleWithPreviousVersion) {
return connectionProvider
.getWriteConnection(new RouteDecisionBuilder(Reason.RW_API_CALL))
.getClientInfo();
} else {
return connectionProvider
.getReadConnection(new RouteDecisionBuilder(Reason.RO_API_CALL))
.getClientInfo();
}
return connectionProvider
.getReadConnection(new RouteDecisionBuilder(Reason.RO_API_CALL))
.getClientInfo();
}

@Override
Expand Down

0 comments on commit 096dcc0

Please sign in to comment.