Skip to content

Commit

Permalink
refactor(dependency): replace javax with jakarta and HandlerIntercept…
Browse files Browse the repository at this point in the history
…orAdapter with HandlerInterceptor during upgrade of spring boot 3.0.x

Spring Boot 3.0 has migrated from Java EE to Jakarta EE APIs for all dependencies.
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Release-Notes#third-party-library-upgrades
So, replacing the imports with `javax` to `jakarta`.

Since `org.springframework.web.servlet.handler.HandlerInterceptorAdapter` has been deprecated in springframework 5.3.0. So, replacing it with `org.springframework.web.servlet.HandlerInterceptor`.
spring-projects/spring-framework#25147
terasolunaorg/terasoluna-gfw#991
  • Loading branch information
j-sandy committed Dec 10, 2024
1 parent afd305a commit 316af12
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.netflix.spinnaker.kork.configserver.autoconfig;

import javax.validation.constraints.NotNull;
import jakarta.validation.constraints.NotNull;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Condition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.netflix.spectator.jvm.Jmx;
import com.netflix.spectator.micrometer.MicrometerRegistry;
import io.micrometer.core.instrument.MeterRegistry;
import javax.annotation.PreDestroy;
import jakarta.annotation.PreDestroy;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down
2 changes: 1 addition & 1 deletion kork-credentials-api/kork-credentials-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
api project(":kork-plugins-api")
implementation project(":kork-annotations")
implementation project(":kork-exceptions")
implementation 'javax.annotation:javax.annotation-api'
implementation 'jakarta.annotation:jakarta.annotation-api'

testRuntimeOnly "cglib:cglib-nodep"
testRuntimeOnly "org.objenesis:objenesis"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.netflix.spinnaker.credentials.Credentials;
import com.netflix.spinnaker.credentials.CredentialsRepository;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import lombok.Getter;

public abstract class AbstractCredentialsLoader<T extends Credentials>
Expand Down
2 changes: 1 addition & 1 deletion kork-credentials/kork-credentials.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
implementation 'org.apache.logging.log4j:log4j-api'
implementation "org.springframework.boot:spring-boot"
implementation 'org.springframework.boot:spring-boot-starter-json'
implementation 'javax.annotation:javax.annotation-api'
implementation 'jakarta.annotation:jakarta.annotation-api'
implementation 'org.slf4j:slf4j-api'

testRuntimeOnly "cglib:cglib-nodep"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import com.netflix.config.DynamicConfiguration;
import com.netflix.config.FixedDelayPollingScheduler;
import com.netflix.spinnaker.kork.eureka.EurekaAutoConfiguration;
import jakarta.annotation.PreDestroy;
import java.util.*;
import java.util.concurrent.TimeUnit;
import javax.annotation.PreDestroy;
import org.apache.commons.configuration.AbstractConfiguration;
import org.apache.commons.configuration.CompositeConfiguration;
import org.springframework.beans.BeansException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import com.netflix.spinnaker.kork.discovery.InstanceStatus;
import com.netflix.spinnaker.kork.discovery.RemoteStatusChangedEvent;
import com.netflix.spinnaker.kork.exceptions.SystemException;
import jakarta.annotation.PreDestroy;
import java.util.Objects;
import javax.annotation.PreDestroy;
import org.springframework.context.ApplicationEventPublisher;

public class EurekaStatusSubscriber implements DiscoveryStatusPublisher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.netflix.spectator.api.patterns.LongTaskTimer;
import com.netflix.spinnaker.kork.jedis.RedisClientDelegate;
import com.netflix.spinnaker.kork.lock.RefreshableLockManager;
import jakarta.annotation.Nonnull;
import jakarta.annotation.PreDestroy;
import java.io.IOException;
import java.time.Clock;
import java.time.Duration;
Expand All @@ -34,8 +36,6 @@
import java.util.Optional;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nonnull;
import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
2 changes: 1 addition & 1 deletion kork-plugins-api/kork-plugins-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
api(platform(project(":spinnaker-dependencies")))

api "org.slf4j:slf4j-api"
api "javax.annotation:javax.annotation-api"
api "jakarta.annotation:jakarta.annotation-api"
api project(":kork-annotations")
api "org.pf4j:pf4j"

Expand Down
2 changes: 1 addition & 1 deletion kork-pubsub-aws/kork-pubsub-aws.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
implementation project(':kork-pubsub')

implementation 'org.springframework.boot:spring-boot-autoconfigure'
implementation 'javax.validation:validation-api'
implementation 'jakarta.validation:jakarta.validation-api'

api 'com.amazonaws:aws-java-sdk-sns'
api 'com.amazonaws:aws-java-sdk-sqs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import com.netflix.spinnaker.kork.pubsub.PubsubPublishers;
import com.netflix.spinnaker.kork.pubsub.aws.config.AmazonPubsubProperties;
import com.netflix.spinnaker.kork.pubsub.model.PubsubPublisher;
import jakarta.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import com.netflix.spinnaker.kork.pubsub.aws.api.AmazonPubsubMessageHandlerFactory;
import com.netflix.spinnaker.kork.pubsub.aws.config.AmazonPubsubProperties;
import com.netflix.spinnaker.kork.pubsub.model.PubsubSubscriber;
import jakarta.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.netflix.spinnaker.kork.pubsub.aws.SQSSubscriberProvider;
import com.netflix.spinnaker.kork.pubsub.aws.api.AmazonMessageAcknowledger;
import com.netflix.spinnaker.kork.pubsub.aws.api.AmazonPubsubMessageHandlerFactory;
import javax.validation.Valid;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package com.netflix.spinnaker.kork.pubsub.aws.config;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import java.util.Collections;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import com.netflix.spinnaker.kork.web.exceptions.BaseExceptionHandlers;
import com.netflix.spinnaker.kork.web.exceptions.ExceptionMessageDecorator;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
Expand Down
2 changes: 1 addition & 1 deletion kork-sql/kork-sql.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
api "com.zaxxer:HikariCP"

implementation 'com.github.blagerweij:liquibase-sessionlock:1.5.0'
implementation "javax.validation:validation-api"
implementation "jakarta.validation:jakarta.validation-api"
implementation "org.hibernate.validator:hibernate-validator"

testImplementation project(":kork-sql-test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package com.netflix.spinnaker.kork.sql.config
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.validation.annotation.Validated
import java.sql.Connection
import javax.validation.Constraint
import javax.validation.ConstraintValidator
import javax.validation.ConstraintValidatorContext
import jakarta.validation.Constraint
import jakarta.validation.ConstraintValidator
import jakarta.validation.ConstraintValidatorContext
import kotlin.reflect.KClass

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package com.netflix.spinnaker.config;

import jakarta.annotation.PostConstruct;
import java.util.regex.Pattern;
import javax.annotation.PostConstruct;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.security.core.context.SecurityContextImpl
import org.springframework.security.core.userdetails.UserDetails

import javax.servlet.Filter
import javax.servlet.FilterChain
import javax.servlet.FilterConfig
import javax.servlet.ServletException
import javax.servlet.ServletRequest
import javax.servlet.ServletResponse
import javax.servlet.http.HttpServletRequest
import jakarta.servlet.Filter
import jakarta.servlet.FilterChain
import jakarta.servlet.FilterConfig
import jakarta.servlet.ServletException
import jakarta.servlet.ServletRequest
import jakarta.servlet.ServletResponse
import jakarta.servlet.http.HttpServletRequest
import java.security.cert.X509Certificate

@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import com.netflix.spinnaker.security.AuthenticatedRequest;
import com.netflix.spinnaker.security.AuthenticatedRequestDecorator;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.netflix.spinnaker.kork.web.exceptions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import com.google.common.io.CharStreams;
import com.netflix.spinnaker.kork.exceptions.HasAdditionalAttributes;
import com.netflix.spinnaker.kork.exceptions.UserException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.AnnotationUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
import com.netflix.spectator.api.Registry;
import com.netflix.spectator.api.histogram.PercentileDistributionSummary;
import com.netflix.spectator.api.histogram.PercentileTimer;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
* An interceptor that logs Controller metrics to an underlying {@link
Expand All @@ -43,7 +43,7 @@
* 500, etc.) - success (true/false depending on whether the request resulted in an exception) -
* cause (if success == false, the name of the raised exception)
*/
public class MetricsInterceptor extends HandlerInterceptorAdapter {
public class MetricsInterceptor implements HandlerInterceptor {
static final String TIMER_ATTRIBUTE = "Metrics_startTime";

private final Registry registry;
Expand Down

0 comments on commit 316af12

Please sign in to comment.