Skip to content

Commit c465a00

Browse files
committed
Cleanup
1 parent 85bb5c5 commit c465a00

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

wrapper/src/main/java/software/amazon/jdbc/plugin/failover/ClusterAwareReaderFailoverHandler.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,16 @@
3333
import java.util.concurrent.TimeUnit;
3434
import java.util.concurrent.TimeoutException;
3535
import java.util.logging.Logger;
36-
import software.amazon.jdbc.ConnectionPluginManager;
3736
import software.amazon.jdbc.HostRole;
3837
import software.amazon.jdbc.HostSpec;
39-
import software.amazon.jdbc.PartialPluginService;
4038
import software.amazon.jdbc.PluginService;
4139
import software.amazon.jdbc.hostavailability.HostAvailability;
4240
import software.amazon.jdbc.util.ExecutorFactory;
4341
import software.amazon.jdbc.util.FullServicesContainer;
44-
import software.amazon.jdbc.util.FullServicesContainerImpl;
4542
import software.amazon.jdbc.util.Messages;
4643
import software.amazon.jdbc.util.PropertyUtils;
4744
import software.amazon.jdbc.util.ServiceUtility;
4845
import software.amazon.jdbc.util.Utils;
49-
import software.amazon.jdbc.util.connection.ConnectionService;
5046

5147
/**
5248
* An implementation of ReaderFailoverHandler.

wrapper/src/main/java/software/amazon/jdbc/util/connection/ConnectionService.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
import software.amazon.jdbc.HostSpec;
2323
import software.amazon.jdbc.PluginService;
2424

25+
/**
26+
* @deprecated This interface is deprecated and will be removed in a future version. Use
27+
* {@link software.amazon.jdbc.util.ServiceUtility#createServiceContainer} followed by
28+
* {@link PluginService#forceConnect} instead.
29+
*/
30+
@Deprecated
2531
public interface ConnectionService {
2632
/**
2733
* Creates an auxiliary connection. Auxiliary connections are driver-internal connections that accomplish various
@@ -31,8 +37,10 @@ public interface ConnectionService {
3137
* @param props the properties for the auxiliary connection.
3238
* @return a new connection to the given host using the given props.
3339
* @throws SQLException if an error occurs while opening the connection.
40+
* @deprecated Use {@link software.amazon.jdbc.util.ServiceUtility#createServiceContainer} followed by
41+
* {@link PluginService#forceConnect} instead.
3442
*/
35-
Connection open(HostSpec hostSpec, Properties props) throws SQLException;
43+
@Deprecated Connection open(HostSpec hostSpec, Properties props) throws SQLException;
3644

37-
PluginService getPluginService();
45+
@Deprecated PluginService getPluginService();
3846
}

wrapper/src/main/java/software/amazon/jdbc/util/connection/ConnectionServiceImpl.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package software.amazon.jdbc.util.connection;
1818

19+
import com.mchange.v2.util.PropertiesUtils;
1920
import java.sql.Connection;
2021
import java.sql.SQLException;
2122
import java.util.Properties;
@@ -28,15 +29,26 @@
2829
import software.amazon.jdbc.targetdriverdialect.TargetDriverDialect;
2930
import software.amazon.jdbc.util.FullServicesContainer;
3031
import software.amazon.jdbc.util.FullServicesContainerImpl;
32+
import software.amazon.jdbc.util.PropertyUtils;
3133
import software.amazon.jdbc.util.monitoring.MonitorService;
3234
import software.amazon.jdbc.util.storage.StorageService;
3335
import software.amazon.jdbc.util.telemetry.TelemetryFactory;
3436

37+
/**
38+
* @deprecated This class is deprecated and will be removed in a future version. Use
39+
* {@link software.amazon.jdbc.util.ServiceUtility#createServiceContainer} followed by
40+
* {@link PluginService#forceConnect} instead.
41+
*/
42+
@Deprecated
3543
public class ConnectionServiceImpl implements ConnectionService {
3644
protected final String targetDriverProtocol;
3745
protected final ConnectionPluginManager pluginManager;
3846
protected final PluginService pluginService;
3947

48+
/**
49+
* @deprecated Use {@link software.amazon.jdbc.util.ServiceUtility#createServiceContainer} instead.
50+
*/
51+
@Deprecated
4052
public ConnectionServiceImpl(
4153
StorageService storageService,
4254
MonitorService monitorService,
@@ -58,9 +70,10 @@ public ConnectionServiceImpl(
5870
telemetryFactory);
5971
servicesContainer.setConnectionPluginManager(this.pluginManager);
6072

73+
Properties propsCopy = PropertyUtils.copyProperties(props);
6174
PartialPluginService partialPluginService = new PartialPluginService(
6275
servicesContainer,
63-
props,
76+
propsCopy,
6477
originalUrl,
6578
this.targetDriverProtocol,
6679
driverDialect,
@@ -72,15 +85,17 @@ public ConnectionServiceImpl(
7285
servicesContainer.setPluginManagerService(partialPluginService);
7386

7487
this.pluginService = partialPluginService;
75-
this.pluginManager.init(servicesContainer, props, partialPluginService, null);
88+
this.pluginManager.init(servicesContainer, propsCopy, partialPluginService, null);
7689
}
7790

7891
@Override
92+
@Deprecated
7993
public Connection open(HostSpec hostSpec, Properties props) throws SQLException {
8094
return this.pluginManager.forceConnect(this.targetDriverProtocol, hostSpec, props, true, null);
8195
}
8296

8397
@Override
98+
@Deprecated
8499
public PluginService getPluginService() {
85100
return this.pluginService;
86101
}

wrapper/src/test/java/software/amazon/jdbc/plugin/failover/FailoverConnectionPluginTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import software.amazon.jdbc.util.FullServicesContainer;
6464
import software.amazon.jdbc.util.RdsUrlType;
6565
import software.amazon.jdbc.util.SqlState;
66-
import software.amazon.jdbc.util.connection.ConnectionService;
6766
import software.amazon.jdbc.util.telemetry.GaugeCallable;
6867
import software.amazon.jdbc.util.telemetry.TelemetryContext;
6968
import software.amazon.jdbc.util.telemetry.TelemetryCounter;
@@ -82,7 +81,6 @@ class FailoverConnectionPluginTest {
8281
.host("reader1").port(1234).role(HostRole.READER).build());
8382

8483
@Mock FullServicesContainer mockContainer;
85-
@Mock ConnectionService mockConnectionService;
8684
@Mock PluginService mockPluginService;
8785
@Mock Connection mockConnection;
8886
@Mock HostSpec mockHostSpec;
@@ -143,7 +141,7 @@ void init() throws SQLException {
143141
}
144142

145143
@Test
146-
void test_notifyNodeListChanged_withFailoverDisabled() throws SQLException {
144+
void test_notifyNodeListChanged_withFailoverDisabled() {
147145
properties.setProperty(FailoverConnectionPlugin.ENABLE_CLUSTER_AWARE_FAILOVER.name, "false");
148146
final Map<String, EnumSet<NodeChangeOptions>> changes = new HashMap<>();
149147

@@ -155,7 +153,7 @@ void test_notifyNodeListChanged_withFailoverDisabled() throws SQLException {
155153
}
156154

157155
@Test
158-
void test_notifyNodeListChanged_withValidConnectionNotInTopology() throws SQLException {
156+
void test_notifyNodeListChanged_withValidConnectionNotInTopology() {
159157
final Map<String, EnumSet<NodeChangeOptions>> changes = new HashMap<>();
160158
changes.put("cluster-host/", EnumSet.of(NodeChangeOptions.NODE_DELETED));
161159
changes.put("instance/", EnumSet.of(NodeChangeOptions.NODE_ADDED));
@@ -351,7 +349,7 @@ void test_failoverWriter_successFailover() throws SQLException {
351349
}
352350

353351
@Test
354-
void test_invalidCurrentConnection_withNoConnection() throws SQLException {
352+
void test_invalidCurrentConnection_withNoConnection() {
355353
when(mockPluginService.getCurrentConnection()).thenReturn(null);
356354
initializePlugin();
357355
spyPlugin.invalidateCurrentConnection();
@@ -376,7 +374,7 @@ void test_invalidateCurrentConnection_inTransaction() throws SQLException {
376374
}
377375

378376
@Test
379-
void test_invalidateCurrentConnection_notInTransaction() throws SQLException {
377+
void test_invalidateCurrentConnection_notInTransaction() {
380378
when(mockPluginService.isInTransaction()).thenReturn(false);
381379
when(mockHostSpec.getHost()).thenReturn("host");
382380
when(mockHostSpec.getPort()).thenReturn(123);
@@ -437,7 +435,7 @@ void test_execute_withDirectExecute() throws SQLException {
437435
verify(mockHostListProvider, never()).getRdsUrlType();
438436
}
439437

440-
private void initializePlugin() throws SQLException {
438+
private void initializePlugin() {
441439
spyPlugin = spy(new FailoverConnectionPlugin(mockContainer, properties));
442440
spyPlugin.setWriterFailoverHandler(mockWriterFailoverHandler);
443441
spyPlugin.setReaderFailoverHandler(mockReaderFailoverHandler);

0 commit comments

Comments
 (0)