Skip to content

Commit a31c1e0

Browse files
committed
fix spotbugs and checkstyle
1 parent d470d04 commit a31c1e0

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

build-tools/src/main/resources/software/amazon/awssdk/spotbugs-suppressions.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,8 @@
359359
<Class name="software.amazon.awssdk.v2migration.EnumCasingToV2$Visitor"/>
360360
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
361361
</Match>
362+
<Match>
363+
<Class name="software.amazon.awssdk.utils.uri.SdkURI" />
364+
<Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" />
365+
</Match>
362366
</FindBugsFilter>

utils/src/main/java/software/amazon/awssdk/utils/uri/SdkURI.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626

2727
/**
2828
* Global cache for account-id based URI. Prevent calling new URI constructor for the same string, which can cause performance
29-
* issues with some uri pattern.
30-
* Do not directly depend on this class, it will be removed in the future.
29+
* issues with some uri pattern. Do not directly depend on this class, it will be removed in the future.
3130
*/
3231
@SdkProtectedApi
3332
public final class SdkURI {
34-
private final String HTTPS_PREFIX = "https://";
35-
private final String HTTP_PREFIX = "http://";
33+
private static final String HTTPS_PREFIX = "https://";
34+
private static final String HTTP_PREFIX = "http://";
3635

3736
private static final Logger log = Logger.loggerFor(SdkURI.class);
3837

@@ -71,7 +70,7 @@ public URI newURI(String s) throws URISyntaxException {
7170
return uri;
7271
} catch (IllegalArgumentException e) {
7372
// URI.create() wraps the URISyntaxException thrown by new URI in a IllegalArgumentException, we need to unwrap it
74-
if (e.getCause() != null && e.getCause() instanceof URISyntaxException) {
73+
if (e.getCause() instanceof URISyntaxException) {
7574
throw (URISyntaxException) e.getCause();
7675
}
7776
throw e;
@@ -81,7 +80,7 @@ public URI newURI(String s) throws URISyntaxException {
8180
public URI newURI(String scheme,
8281
String userInfo, String host, int port,
8382
String path, String query, String fragment)
84-
throws URISyntaxException {
83+
throws URISyntaxException {
8584
if (!isAccountIdUri(host)) {
8685
log.trace(() -> "skipping cache for host" + host);
8786
return new URI(scheme, userInfo, host, port, path, query, fragment);
@@ -96,7 +95,7 @@ public URI newURI(String scheme,
9695
public URI newURI(String scheme,
9796
String authority,
9897
String path, String query, String fragment)
99-
throws URISyntaxException {
98+
throws URISyntaxException {
10099
if (!isAccountIdUri(authority)) {
101100
log.trace(() -> "skipping cache for authority" + authority);
102101
return new URI(scheme, authority, path, query, fragment);
@@ -208,7 +207,9 @@ public boolean equals(Object o) {
208207
}
209208

210209
HostConstructorArgs that = (HostConstructorArgs) o;
211-
return port == that.port && Objects.equals(scheme, that.scheme) && Objects.equals(userInfo, that.userInfo) && Objects.equals(host, that.host) && Objects.equals(path, that.path) && Objects.equals(query, that.query) && Objects.equals(fragment, that.fragment);
210+
return port == that.port && Objects.equals(scheme, that.scheme) && Objects.equals(userInfo, that.userInfo)
211+
&& Objects.equals(host, that.host) && Objects.equals(path, that.path) && Objects.equals(query, that.query)
212+
&& Objects.equals(fragment, that.fragment);
212213
}
213214

214215
@Override
@@ -255,8 +256,9 @@ public boolean equals(Object o) {
255256
}
256257

257258
AuthorityConstructorArgs that = (AuthorityConstructorArgs) o;
258-
return Objects.equals(scheme, that.scheme) && Objects.equals(authority, that.authority) && Objects.equals(path,
259-
that.path) && Objects.equals(query, that.query) && Objects.equals(fragment, that.fragment);
259+
return Objects.equals(scheme, that.scheme) && Objects.equals(authority, that.authority)
260+
&& Objects.equals(path, that.path) && Objects.equals(query, that.query)
261+
&& Objects.equals(fragment, that.fragment);
260262
}
261263

262264
@Override

0 commit comments

Comments
 (0)