Skip to content

Commit 8e29b93

Browse files
authored
Cleanup various warnings (#170)
1 parent e11faea commit 8e29b93

4 files changed

Lines changed: 18 additions & 21 deletions

File tree

stubbornjava-common/src/main/java/com/stubbornjava/common/DeterministicObjectMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public static ObjectMapper create(ObjectMapper original, CustomComparators custo
5353
* before we added our module to it. If we have a Collection -> Collection converter
5454
* it delegates to itself and infinite loops until the stack overflows.
5555
*/
56-
private static class CustomDelegatingSerializerProvider extends StdDelegatingSerializer
56+
@SuppressWarnings("serial")
57+
private static class CustomDelegatingSerializerProvider extends StdDelegatingSerializer
5758
{
5859
private final SerializerProvider serializerProvider;
5960

stubbornjava-common/src/main/java/com/stubbornjava/common/GraphiteHttpSender.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import okhttp3.OkHttpClient;
1515
import okhttp3.Request;
1616
import okhttp3.RequestBody;
17-
import okhttp3.logging.HttpLoggingInterceptor;
18-
import okhttp3.logging.HttpLoggingInterceptor.Level;
1917

2018
// {{start:sender}}
2119
/**
@@ -26,7 +24,8 @@
2624
*
2725
*/
2826
class GraphiteHttpSender implements GraphiteSender {
29-
private static final Logger log = LoggerFactory.getLogger(GraphiteHttpSender.class);
27+
@SuppressWarnings("unused")
28+
private static final Logger log = LoggerFactory.getLogger(GraphiteHttpSender.class);
3029

3130
private final OkHttpClient client;
3231
private final String host;
@@ -58,9 +57,9 @@ public void send(String name, String value, long timestamp) throws IOException {
5857
public void flush() throws IOException {
5958
Request request = new Request.Builder()
6059
.url(host + "/metrics")
61-
.post(RequestBody.create(MediaType.parse("application/json"), Json.serializer().toByteArray(metrics)))
60+
.post(RequestBody.Companion.create(Json.serializer().toByteArray(metrics), MediaType.Companion.parse("application/json")))
6261
.build();
63-
String response = Retry.retryUntilSuccessfulWithBackoff(() -> client.newCall(request).execute());
62+
Retry.retryUntilSuccessfulWithBackoff(() -> client.newCall(request).execute());
6463
metrics.clear();
6564
}
6665

@@ -76,14 +75,6 @@ public int getFailures() {
7675
return 0;
7776
}
7877

79-
private static final HttpLoggingInterceptor getLogger(Level level) {
80-
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor((msg) -> {
81-
log.debug(msg);
82-
});
83-
loggingInterceptor.setLevel(level);
84-
return loggingInterceptor;
85-
}
86-
8778
private static final class GraphiteMetric {
8879
private final String name;
8980
private final int interval;
@@ -100,16 +91,20 @@ public GraphiteMetric(@JsonProperty("name") String name,
10091
this.time = time;
10192
}
10293

103-
public String getName() {
94+
@SuppressWarnings("unused")
95+
public String getName() {
10496
return name;
10597
}
106-
public int getInterval() {
98+
@SuppressWarnings("unused")
99+
public int getInterval() {
107100
return interval;
108101
}
109-
public double getValue() {
102+
@SuppressWarnings("unused")
103+
public double getValue() {
110104
return value;
111105
}
112-
public long getTime() {
106+
@SuppressWarnings("unused")
107+
public long getTime() {
113108
return time;
114109
}
115110
}

stubbornjava-common/src/main/java/com/stubbornjava/common/Http.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import okhttp3.Response;
1616

1717
public class Http {
18-
private static final Logger log = LoggerFactory.getLogger(Http.class);
18+
@SuppressWarnings("unused")
19+
private static final Logger log = LoggerFactory.getLogger(Http.class);
1920

2021
// {{start:get}}
2122
public static Response get(OkHttpClient client, String url) {

stubbornjava-common/src/main/java/com/stubbornjava/common/HttpClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ private HttpClient() {
4242
});
4343
static {
4444
if (log.isDebugEnabled()) {
45-
loggingInterceptor.setLevel(Level.BASIC);
45+
loggingInterceptor.level(Level.BASIC);
4646
} else if (log.isTraceEnabled()) {
47-
loggingInterceptor.setLevel(Level.BODY);
47+
loggingInterceptor.level(Level.BODY);
4848
}
4949
}
5050

0 commit comments

Comments
 (0)