diff --git a/plume-conf/src/main/java/com/coreoz/plume/conf/RequiredIncluder.java b/plume-conf/src/main/java/com/coreoz/plume/conf/RequiredIncluder.java
index aa9cebe..d9a7e15 100644
--- a/plume-conf/src/main/java/com/coreoz/plume/conf/RequiredIncluder.java
+++ b/plume-conf/src/main/java/com/coreoz/plume/conf/RequiredIncluder.java
@@ -14,7 +14,7 @@
/**
* Config includer that forces all includes to resolve or else fail with a ConfigException.
- *
+ *
* See https://github.com/lightbend/config/issues/587
*/
public class RequiredIncluder implements ConfigIncluder, ConfigIncluderFile, ConfigIncluderURL,
@@ -42,8 +42,8 @@ public ConfigObject include(ConfigIncludeContext context, String what) {
@Override
public ConfigObject includeResources(ConfigIncludeContext context, String what) {
context = verifyDelegateAndStrictContext(context);
- if (delegate instanceof ConfigIncluderClasspath) {
- return ((ConfigIncluderClasspath) delegate).includeResources(context, what);
+ if (delegate instanceof ConfigIncluderClasspath configIncluderClasspath) {
+ return configIncluderClasspath.includeResources(context, what);
}
return ConfigFactory.parseResources(what, context.parseOptions()).root();
}
@@ -51,8 +51,8 @@ public ConfigObject includeResources(ConfigIncludeContext context, String what)
@Override
public ConfigObject includeFile(ConfigIncludeContext context, File what) {
context = verifyDelegateAndStrictContext(context);
- if (delegate instanceof ConfigIncluderFile) {
- return ((ConfigIncluderFile) delegate).includeFile(context, what);
+ if (delegate instanceof ConfigIncluderFile configIncluderFile) {
+ return configIncluderFile.includeFile(context, what);
}
return ConfigFactory.parseFile(what, context.parseOptions()).root();
}
@@ -60,8 +60,8 @@ public ConfigObject includeFile(ConfigIncludeContext context, File what) {
@Override
public ConfigObject includeURL(ConfigIncludeContext context, URL what) {
context = verifyDelegateAndStrictContext(context);
- if (delegate instanceof ConfigIncluderURL) {
- return ((ConfigIncluderURL) delegate).includeURL(context, what);
+ if (delegate instanceof ConfigIncluderURL configIncluderUrl) {
+ return configIncluderUrl.includeURL(context, what);
}
return ConfigFactory.parseURL(what, context.parseOptions()).root();
}
diff --git a/plume-mail/src/test/java/com/coreoz/plume/mail/MailerProviderTest.java b/plume-mail/src/test/java/com/coreoz/plume/mail/MailerProviderTest.java
index cbc71c7..9663f73 100644
--- a/plume-mail/src/test/java/com/coreoz/plume/mail/MailerProviderTest.java
+++ b/plume-mail/src/test/java/com/coreoz/plume/mail/MailerProviderTest.java
@@ -1,17 +1,16 @@
package com.coreoz.plume.mail;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
import org.assertj.core.api.Assertions;
import org.junit.Test;
-import com.google.common.collect.ImmutableMap;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
+import java.util.Map;
public class MailerProviderTest {
-
@Test
public void should_generate_well_form_property_file() {
- Config config = ConfigFactory.parseMap(ImmutableMap.of(
+ Config config = ConfigFactory.parseMap(Map.of(
"mail.\"javaxmail.debug\"", "true",
"mail.transportstrategy", "SMTP_SSL"
));
@@ -22,5 +21,4 @@ public void should_generate_well_form_property_file() {
+ "simplejavamail.transportstrategy=SMTP_SSL"
);
}
-
}
diff --git a/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/health/healthchecks/DatabaseHealthCheck.java b/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/health/healthchecks/DatabaseHealthCheck.java
index 3bcaa15..425e7b6 100644
--- a/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/health/healthchecks/DatabaseHealthCheck.java
+++ b/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/health/healthchecks/DatabaseHealthCheck.java
@@ -2,13 +2,12 @@
import com.codahale.metrics.health.HealthCheck;
import com.coreoz.plume.db.transaction.TransactionManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import lombok.extern.slf4j.Slf4j;
import java.sql.SQLException;
+@Slf4j
public class DatabaseHealthCheck extends HealthCheck {
- private static final Logger logger = LoggerFactory.getLogger(DatabaseHealthCheck.class);
private final TransactionManager transactionManager;
public DatabaseHealthCheck(TransactionManager transactionManager) {
diff --git a/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/metrics/MetricsCheckBuilder.java b/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/metrics/MetricsCheckBuilder.java
index 88db257..1c3d6d0 100644
--- a/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/metrics/MetricsCheckBuilder.java
+++ b/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/metrics/MetricsCheckBuilder.java
@@ -13,8 +13,8 @@ public class MetricsCheckBuilder {
private final MetricRegistry metricRegistry = new MetricRegistry();
public MetricsCheckBuilder registerMetric(String name, Metric metric) {
- if (metric instanceof MetricSet) {
- this.metricRegistry.registerAll(name, (MetricSet) metric);
+ if (metric instanceof MetricSet metricSet) {
+ this.metricRegistry.registerAll(name, metricSet);
} else {
this.metricRegistry.register(name, metric);
}
diff --git a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/async/AsyncJersey.java b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/async/AsyncJersey.java
index 777d914..d58643e 100644
--- a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/async/AsyncJersey.java
+++ b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/async/AsyncJersey.java
@@ -1,26 +1,21 @@
package com.coreoz.plume.jersey.async;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.BiConsumer;
-
-import javax.ws.rs.container.AsyncResponse;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.coreoz.plume.jersey.errors.ErrorResponse;
import com.coreoz.plume.jersey.errors.WsError;
-import com.google.common.collect.ImmutableList;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.ws.rs.container.AsyncResponse;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.BiConsumer;
/**
* Provides a bridge between JAX-RS asynchronous API and Java 8 asynchronous API
* @see CompletableFuture
* @see AsyncResponse
*/
+@Slf4j
public class AsyncJersey {
-
- private static final Logger logger = LoggerFactory.getLogger(AsyncJersey.class);
-
/**
* Provides a {@link BiConsumer} from an {@link AsyncResponse}
* that should be called when a {@link CompletableFuture} is terminated.
@@ -41,10 +36,8 @@ public class AsyncJersey {
asyncResponse.resume(responseBody);
} else {
logger.error("An exception was raised during the promise execution", exception);
- asyncResponse.resume(new ErrorResponse(WsError.INTERNAL_ERROR, ImmutableList.of()));
+ asyncResponse.resume(new ErrorResponse(WsError.INTERNAL_ERROR, List.of()));
}
};
}
-
}
-
diff --git a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/Validators.java b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/Validators.java
index c5c1f88..cbb3280 100644
--- a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/Validators.java
+++ b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/Validators.java
@@ -3,10 +3,11 @@
import org.apache.commons.validator.routines.EmailValidator;
import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.List;
+
/**
* Provides common validators that will throw {@link WsException}
* when the input data does not pass the validator.
@@ -21,28 +22,28 @@ public class Validators {
public static @NotNull String checkRequired(@NotNull String fieldName, @Nullable String fieldValue) {
if(Strings.isNullOrEmpty(fieldValue)) {
- throw new WsException(WsError.FIELD_REQUIRED, ImmutableList.of(fieldName));
+ throw new WsException(WsError.FIELD_REQUIRED, List.of(fieldName));
}
return fieldValue;
}
public static @NotNull T checkRequired(@NotNull String fieldName, @Nullable T fieldValue) {
if(fieldValue == null) {
- throw new WsException(WsError.FIELD_REQUIRED, ImmutableList.of(fieldName));
+ throw new WsException(WsError.FIELD_REQUIRED, List.of(fieldName));
}
return fieldValue;
}
public static @Nullable String checkEmail(@NotNull String fieldName, @Nullable String fieldValue) {
if(!EmailValidator.getInstance().isValid(fieldValue)) {
- throw new WsException(WsError.EMAIL_INVALID, ImmutableList.of(fieldName));
+ throw new WsException(WsError.EMAIL_INVALID, List.of(fieldName));
}
return fieldValue;
}
public static @Nullable String checkHexaColor(@NotNull String fieldName, @Nullable String fieldValue) {
if(fieldValue != null && !fieldValue.matches("[0-9a-fA-F]{6}")) {
- throw new WsException(WsError.COLOR_INVALID, ImmutableList.of(fieldName));
+ throw new WsException(WsError.COLOR_INVALID, List.of(fieldName));
}
return fieldValue;
}
@@ -50,7 +51,7 @@ public class Validators {
public static @Nullable String checkHexaColorWithStartingHash(@NotNull String fieldName, @Nullable String fieldValue) {
if(fieldValue != null) {
if (!fieldValue.startsWith("#")) {
- throw new WsException(WsError.COLOR_INVALID, ImmutableList.of(fieldName));
+ throw new WsException(WsError.COLOR_INVALID, List.of(fieldName));
}
return "#" + checkHexaColor(fieldName, fieldValue.substring(1));
}
diff --git a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/WsException.java b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/WsException.java
index 769af87..5d48c50 100644
--- a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/WsException.java
+++ b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/WsException.java
@@ -1,8 +1,6 @@
package com.coreoz.plume.jersey.errors;
-import com.google.common.collect.ImmutableList;
-
-import java.io.Serial;
+import java.util.List;
/**
* A {@link RuntimeException} that stops the execution of the web-service
@@ -16,11 +14,11 @@ public class WsException extends RuntimeException {
private final Iterable statusArguments;
public WsException(WsError error) {
- this(error, ImmutableList.of());
+ this(error, List.of());
}
public WsException(WsError error, String... statusArguments) {
- this(error, ImmutableList.copyOf(statusArguments));
+ this(error, List.of(statusArguments));
}
public WsException(WsError error, Iterable statusArguments) {
diff --git a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/WsJacksonJsonProvider.java b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/WsJacksonJsonProvider.java
index fc709ef..36657d5 100644
--- a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/WsJacksonJsonProvider.java
+++ b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/errors/WsJacksonJsonProvider.java
@@ -1,30 +1,25 @@
package com.coreoz.plume.jersey.errors;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.jaxrs.cfg.Annotations;
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.jaxrs.cfg.Annotations;
-import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
-
/**
* A Jackson JSON provider that throws a {@link JsonRequestParseException}
* during the parsing.
* It is useful to return proper 400 errors when JSON request input is not valid
* @see JacksonJaxbJsonProvider
*/
+@Slf4j
public class WsJacksonJsonProvider extends JacksonJaxbJsonProvider {
-
- private static final Logger logger = LoggerFactory.getLogger(WsJacksonJsonProvider.class);
-
public WsJacksonJsonProvider() {
super();
}
@@ -48,5 +43,4 @@ public Object readFrom(Class