Skip to content

Commit d804e88

Browse files
authored
Merge branch 'main' into gh-2110-regex
2 parents 8fc4f8e + 7cf98c3 commit d804e88

42 files changed

Lines changed: 96 additions & 95 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
strategy:
3232
matrix:
3333
os: [macos-latest, windows-latest, ubuntu-latest]
34-
java-version: ["8", "11", "17"]
34+
java-version: ["8", "11", "17", "24"]
3535
fail-fast: false
3636
permissions:
3737
contents: "read"

core/src/main/java/com/google/cloud/sql/core/CloudSqlInstanceName.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public static boolean isValidInstanceName(String connectionName) {
9797
* @param connectionName instance connection name in the format "PROJECT_ID:REGION_ID:INSTANCE_ID"
9898
* @param domainName the domain name used to look up the instance, or null.
9999
*/
100+
@SuppressWarnings("ExpensiveLenientFormatString")
100101
CloudSqlInstanceName(String connectionName, String domainName) {
101102
Matcher matcher = CONNECTION_NAME.matcher(connectionName);
102103
checkArgument(

core/src/main/java/com/google/cloud/sql/core/JndiDnsResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class JndiDnsResolver implements DnsResolver {
5353
* @throws javax.naming.NameNotFoundException when the domain name did not resolve.
5454
*/
5555
@Override
56-
@SuppressWarnings("JdkObsolete")
56+
@SuppressWarnings({"JdkObsolete", "BanJNDI"})
5757
public Collection<String> resolveTxt(String domainName)
5858
throws javax.naming.NameNotFoundException {
5959
try {

core/src/main/java/com/google/cloud/sql/core/RefreshCalculator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class RefreshCalculator {
3030
// time to complete.
3131
static final Duration DEFAULT_REFRESH_BUFFER = Duration.ofMinutes(4);
3232

33+
// Suppressing the warning for toSeconds. getSeconds is in JDK 8. toSeconds was only introduced in
34+
// Jdk 1.9
35+
@SuppressWarnings("JavaDurationGetSecondsToToSeconds")
3336
long calculateSecondsUntilNextRefresh(Instant now, Instant expiration) {
3437
Duration timeUntilExp = Duration.between(now, expiration);
3538

core/src/test/java/com/google/cloud/sql/core/ConnectorTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.time.Instant;
4141
import java.util.Collection;
4242
import java.util.Collections;
43+
import java.util.Locale;
4344
import javax.naming.NameNotFoundException;
4445
import javax.net.ssl.SSLHandshakeException;
4546
import org.junit.After;
@@ -111,7 +112,7 @@ public void create_throwsErrorForInvalidTlsCommonNameMismatch()
111112

112113
assertThat(ex)
113114
.hasMessageThat()
114-
.isEqualTo(
115+
.contains(
115116
"Server certificate CN does not match instance name. "
116117
+ "Server certificate CN=myProject:myInstance "
117118
+ "Expected instance name: myProject:wrongwrongwrong");
@@ -522,7 +523,7 @@ public void create_successfulPublicCasConnection() throws IOException, Interrupt
522523
}
523524

524525
private boolean isWindows() {
525-
String os = System.getProperty("os.name").toLowerCase();
526+
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
526527
return os.contains("win");
527528
}
528529

@@ -943,12 +944,12 @@ private static class MockDnsResolver implements DnsResolver {
943944
private final String domainName;
944945
private final String instanceName;
945946

946-
public MockDnsResolver() {
947+
private MockDnsResolver() {
947948
this.domainName = null;
948949
this.instanceName = null;
949950
}
950951

951-
public MockDnsResolver(String domainName, String instanceName) {
952+
private MockDnsResolver(String domainName, String instanceName) {
952953
this.domainName = domainName;
953954
this.instanceName = instanceName;
954955
}
@@ -972,16 +973,16 @@ private static class MutableDnsResolver implements DnsResolver {
972973
private final String domainName;
973974
private String instanceName;
974975

975-
public MutableDnsResolver(String domainName, String instanceName) {
976+
private MutableDnsResolver(String domainName, String instanceName) {
976977
this.domainName = domainName;
977978
this.instanceName = instanceName;
978979
}
979980

980-
public synchronized void setInstanceName(String instanceName) {
981+
private synchronized void setInstanceName(String instanceName) {
981982
this.instanceName = instanceName;
982983
}
983984

984-
public synchronized void clearInstanceName() {
985+
private synchronized void clearInstanceName() {
985986
this.instanceName = null;
986987
}
987988

core/src/test/java/com/google/cloud/sql/core/DefaultConnectionInfoRepositoryIntegrationTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public static void checkEnvVars() {
4545
requiredEnvVars.forEach(
4646
(varName) ->
4747
assertWithMessage(
48-
String.format(
49-
"Environment variable '%s' must be set to perform these tests.", varName))
48+
"Environment variable '%s' must be set to perform these tests.", varName)
5049
.that(System.getenv(varName))
5150
.isNotEmpty());
5251
}

core/src/test/java/com/google/cloud/sql/core/FakeUnixSocketServer.java

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

1717
package com.google.cloud.sql.core;
1818

19+
import static java.nio.charset.StandardCharsets.UTF_8;
20+
1921
import java.io.IOException;
2022
import java.nio.ByteBuffer;
2123
import java.nio.channels.SelectionKey;
@@ -35,7 +37,7 @@
3537
* https://github.com/jnr/jnr-unixsocket/blob/master/src/test/java/jnr/unixsocket/example/UnixServer.java
3638
*/
3739
class FakeUnixSocketServer {
38-
private static Logger log = LoggerFactory.getLogger(FakeUnixSocketServer.class);
40+
private static final Logger log = LoggerFactory.getLogger(FakeUnixSocketServer.class);
3941
private final String path;
4042
private final UnixSocketAddress address;
4143
private UnixServerSocketChannel channel;
@@ -104,24 +106,24 @@ public void run() {
104106
log.info("UnixServer EXIT");
105107
}
106108

107-
static interface Actor {
108-
public boolean rxready();
109+
interface Actor {
110+
boolean rxready();
109111
}
110112

111113
static final class ServerActor implements Actor {
112114
private final UnixServerSocketChannel channel;
113115

114-
public ServerActor(UnixServerSocketChannel channel) {
116+
private ServerActor(UnixServerSocketChannel channel) {
115117
this.channel = channel;
116118
}
117119

118120
@Override
119-
public final boolean rxready() {
121+
public boolean rxready() {
120122
log.info("Handling unix socket connect.");
121123
try {
122124
UnixSocketChannel client = channel.accept();
123125
client.configureBlocking(false);
124-
ByteBuffer response = ByteBuffer.wrap("HELLO\n".getBytes("UTF-8"));
126+
ByteBuffer response = ByteBuffer.wrap("HELLO\n".getBytes(UTF_8));
125127
client.write(response);
126128
log.info("Handling unix socket done.");
127129
return true;

core/src/test/java/com/google/cloud/sql/core/InstanceCheckingTrustManagerFactoryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ private static class TestCase {
176176

177177
private final boolean cas;
178178

179-
public TestCase(
179+
private TestCase(
180180
String desc, String serverName, String icn, String cn, String san, boolean valid) {
181181
this(desc, serverName, icn, cn, san, valid, false);
182182
}
183183

184-
public TestCase(
184+
private TestCase(
185185
String desc,
186186
String serverName,
187187
String icn,

core/src/test/java/com/google/cloud/sql/core/MockAdminApi.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,22 @@ private static class ConnectSettingsRequest {
207207
private final ConnectSettings settings;
208208
private final String baseUrl;
209209

210-
public ConnectSettingsRequest(
210+
private ConnectSettingsRequest(
211211
CloudSqlInstanceName cloudSqlInstanceName, ConnectSettings settings, String baseUrl) {
212212
this.cloudSqlInstanceName = cloudSqlInstanceName;
213213
this.settings = settings;
214214
this.baseUrl = baseUrl;
215215
}
216216

217-
public ConnectSettings getSettings() {
217+
private ConnectSettings getSettings() {
218218
return settings;
219219
}
220220

221-
public CloudSqlInstanceName getCloudSqlInstanceName() {
221+
private CloudSqlInstanceName getCloudSqlInstanceName() {
222222
return cloudSqlInstanceName;
223223
}
224224

225-
public String getBaseUrl() {
225+
private String getBaseUrl() {
226226
return baseUrl;
227227
}
228228
}
@@ -233,7 +233,7 @@ private static class GenerateEphemeralCertRequest {
233233
private final GenerateEphemeralCertResponse generateEphemeralCertResponse;
234234
private final String baseUrl;
235235

236-
public GenerateEphemeralCertRequest(
236+
private GenerateEphemeralCertRequest(
237237
CloudSqlInstanceName instanceConnectionName,
238238
GenerateEphemeralCertResponse generateEphemeralCertResponse,
239239
String baseUrl) {
@@ -242,15 +242,15 @@ public GenerateEphemeralCertRequest(
242242
this.baseUrl = baseUrl;
243243
}
244244

245-
public CloudSqlInstanceName getCloudSqlInstanceName() {
245+
private CloudSqlInstanceName getCloudSqlInstanceName() {
246246
return cloudSqlInstanceName;
247247
}
248248

249-
public GenerateEphemeralCertResponse getGenerateEphemeralCertResponse() {
249+
private GenerateEphemeralCertResponse getGenerateEphemeralCertResponse() {
250250
return generateEphemeralCertResponse;
251251
}
252252

253-
public String getBaseUrl() {
253+
private String getBaseUrl() {
254254
return baseUrl;
255255
}
256256
}
@@ -259,7 +259,7 @@ private static class MockRefreshHandler implements OAuth2RefreshHandler {
259259
private final String refreshToken;
260260
private final Date expirationTime;
261261

262-
public MockRefreshHandler(String refreshToken, Date expirationTime) {
262+
private MockRefreshHandler(String refreshToken, Date expirationTime) {
263263
this.refreshToken = refreshToken;
264264
this.expirationTime = expirationTime;
265265
}

core/src/test/java/com/google/cloud/sql/core/RefreshCalculatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public RefreshCalculatorTest(String name, Duration input, Duration want) {
5757
this.refreshCalculator = new RefreshCalculator();
5858
}
5959

60-
private static final Instant NOW = Instant.now().truncatedTo(SECONDS);
6160
private final RefreshCalculator refreshCalculator;
6261

6362
@Test
6463
public void testDuration() {
64+
final Instant NOW = Instant.now().truncatedTo(SECONDS);
6565
Duration nextRefresh =
6666
Duration.ofSeconds(
6767
refreshCalculator.calculateSecondsUntilNextRefresh(NOW, NOW.plus(input)));

0 commit comments

Comments
 (0)