Skip to content

Commit

Permalink
Core: Bump dependencies (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
And1sS authored Jul 18, 2023
1 parent 7968d87 commit 861540a
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 115 deletions.
46 changes: 23 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version>
<version>3.0.5</version>
<relativePath />
</parent>

Expand All @@ -32,7 +32,7 @@

<project.build.resources.directory>src/main/resources</project.build.resources.directory>
<main.class>org.prebid.cache.PBCacheApplication</main.class>
<junit-jupiter.version>5.3.1</junit-jupiter.version>
<junit-jupiter.version>5.9.2</junit-jupiter.version>

<!-- used for rpm packaging -->
<build.number>0</build.number>
Expand All @@ -51,34 +51,34 @@
<maven-release-plugin.version>3.0.0-M5</maven-release-plugin.version>
<rest-maven-plugin.version>0.1.4</rest-maven-plugin.version>
<spring-boot-maven-plugin.version>2.6.7</spring-boot-maven-plugin.version>
<lettuce-core.version>6.1.8.RELEASE</lettuce-core.version>
<gson.version>2.9.0</gson.version>
<guava.version>31.1-jre</guava.version>
<caffeine.version>3.0.6</caffeine.version>
<lettuce-core.version>6.2.4.RELEASE</lettuce-core.version>
<gson.version>2.10.1</gson.version>
<guava.version>32.0.0-jre</guava.version>
<caffeine.version>3.1.6</caffeine.version>
<disruptor.version>3.4.4</disruptor.version>
<lombok.version>1.18.24</lombok.version>
<metrics-graphite.version>4.0.2</metrics-graphite.version>
<lombok.version>1.18.28</lombok.version>
<metrics-graphite.version>4.2.17</metrics-graphite.version>
<javax.el-api.version>3.0.0</javax.el-api.version>
<reflections.version>0.10.2</reflections.version>
<equals-verifier.version>3.10</equals-verifier.version>
<aerospike-client.version>5.1.11</aerospike-client.version>
<reactor-extra.version>3.4.8</reactor-extra.version>
<wiremock.version>2.27.2</wiremock.version>
<checkstyle-plugin.version>3.1.2</checkstyle-plugin.version>
<checkstyle.version>10.2</checkstyle.version>
<jacoco-plugin.version>0.8.8</jacoco-plugin.version>
<equals-verifier.version>3.14.1</equals-verifier.version>
<aerospike-client.version>6.1.11</aerospike-client.version>
<reactor-extra.version>3.5.1</reactor-extra.version>
<wiremock.version>3.0.0-beta-10</wiremock.version>
<checkstyle-plugin.version>3.3.0</checkstyle-plugin.version>
<checkstyle.version>10.12.1</checkstyle.version>
<jacoco-plugin.version>0.8.10</jacoco-plugin.version>
<awaitility.version>4.2.0</awaitility.version>
<resilience4j.version>1.7.1</resilience4j.version>
<log4j2.version>2.17.2</log4j2.version>
<resilience4j.version>2.1.0</resilience4j.version>
<log4j2.version>2.20.0</log4j2.version>
<javax.validation-api>2.0.1.Final</javax.validation-api>

<!-- Functional Tests -->
<kotest.version>5.3.0</kotest.version>
<kotlin.version>1.6.21</kotlin.version>
<testcontainers.version>1.17.1</testcontainers.version>
<kotest.version>5.5.5</kotest.version>
<kotlin.version>1.8.10</kotlin.version>
<testcontainers.version>1.17.6</testcontainers.version>
<mockserver-client.version>5.13.2</mockserver-client.version>
<ktor.version>2.0.1</ktor.version>
<jackson-kotlin-module.version>2.13.2</jackson-kotlin-module.version>
<ktor.version>2.2.4</ktor.version>
<jackson-kotlin-module.version>2.14.2</jackson-kotlin-module.version>
<docker-maven-plugin.version>0.39.1</docker-maven-plugin.version>
</properties>

Expand Down Expand Up @@ -243,7 +243,7 @@
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core-jvm</artifactId>
<version>1.6.1</version>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
71 changes: 36 additions & 35 deletions src/main/java/org/prebid/cache/handlers/CacheHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ public String toString() {

<T> Mono<T> validateErrorResult(final Mono<T> mono) {
return mono.doOnSuccess(v -> log.debug("{}: {}", type, v))
.onErrorResume(t -> {
// skip overwrite, report first prebid error
if (t instanceof PrebidException) {
// TODO: 19.09.18 move to handleErrorMetrics
applyMetrics(t);
.onErrorResume(t -> {
// skip overwrite, report first prebid error
if (t instanceof PrebidException) {
// TODO: 19.09.18 move to handleErrorMetrics
applyMetrics(t);

if (t instanceof DuplicateKeyException) {
return Mono.error(new BadRequestException(UUID_DUPLICATION));
}
return Mono.error(t);
} else if (t instanceof org.springframework.core.codec.DecodingException) {
return Mono.error(new RequestParsingException(t.toString()));
} else if (t instanceof org.springframework.web.server.UnsupportedMediaTypeStatusException) {
return Mono.error(new UnsupportedMediaTypeException(t.toString()));
} else {
return Mono.error(t);
if (t instanceof DuplicateKeyException) {
return Mono.error(new BadRequestException(UUID_DUPLICATION));
}
});
return Mono.error(t);
} else if (t instanceof org.springframework.core.codec.DecodingException) {
return Mono.error(new RequestParsingException(t.toString()));
} else if (t instanceof org.springframework.web.server.UnsupportedMediaTypeStatusException) {
return Mono.error(new UnsupportedMediaTypeException(t.toString()));
} else {
return Mono.error(t);
}
});
}

// TODO: 19.09.18 refactor this to normal interaction with mono instead of "casting" exceptions to status codes
Expand All @@ -81,35 +81,36 @@ private Mono<ServerResponse> handleErrorMetrics(final Throwable error,
}

return builder.error(Mono.just(error), request)
.doAfterSuccessOrError((v, t) -> {
HttpMethod method = request.method();
if (method == null || t != null || v == null) {
.doOnEach(signal -> {
final var response = signal.get();
HttpMethod method = request.method();
if (method == null || signal.isOnError() || response == null) {
metricsRecorder.markMeterForTag(this.metricTagPrefix,
MetricsRecorder.MeasurementTag.ERROR_UNKNOWN);
} else {
if (response.statusCode() == HttpStatus.INTERNAL_SERVER_ERROR) {
metricsRecorder.markMeterForTag(this.metricTagPrefix,
MetricsRecorder.MeasurementTag.ERROR_UNKNOWN);
} else {
if (v.statusCode() == HttpStatus.INTERNAL_SERVER_ERROR) {
metricsRecorder.markMeterForTag(this.metricTagPrefix,
MetricsRecorder.MeasurementTag.ERROR_UNKNOWN);
} else if (v.statusCode() == HttpStatus.BAD_REQUEST) {
metricsRecorder.markMeterForTag(this.metricTagPrefix,
MetricsRecorder.MeasurementTag.ERROR_BAD_REQUEST);
} else if (v.statusCode() == HttpStatus.NOT_FOUND) {
metricsRecorder.markMeterForTag(this.metricTagPrefix,
MetricsRecorder.MeasurementTag.ERROR_MISSINGID);
}
} else if (response.statusCode() == HttpStatus.BAD_REQUEST) {
metricsRecorder.markMeterForTag(this.metricTagPrefix,
MetricsRecorder.MeasurementTag.ERROR_BAD_REQUEST);
} else if (response.statusCode() == HttpStatus.NOT_FOUND) {
metricsRecorder.markMeterForTag(this.metricTagPrefix,
MetricsRecorder.MeasurementTag.ERROR_MISSINGID);
}
});
}
});
}

Mono<ServerResponse> finalizeResult(final Mono<ServerResponse> mono,
final ServerRequest request,
final MetricsRecorderTimer timerContext) {
// transform to error, if needed and send metrics
return mono.onErrorResume(throwable -> handleErrorMetrics(throwable, request))
.doAfterSuccessOrError((v, t) -> {
if (timerContext != null)
timerContext.stop();
});
.doOnEach(signal -> {
if (timerContext != null)
timerContext.stop();
});
}

void applyMetrics(Throwable t) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ server.undertow.buffer-size: 16384
server.undertow.direct-buffers: true

---
spring.profiles: manage
spring.config.activate.on-profile: manage
management.health.defaults.enabled: true
cors:
enabled: true
Expand All @@ -88,7 +88,7 @@ management:
enabled: true

---
spring.profiles: local
spring.config.activate.on-profile: local
cache.expiry_sec: 300
cache:
min_expiry: 15
Expand All @@ -115,20 +115,20 @@ spring:

---
# dev
spring.profiles: dev
spring.config.activate.on-profile: dev
cache.expiry_sec: 28800
logging.level.root: debug
logging.config: classpath:log4j2-dev.xml

---
# qa
spring.profiles: qa
spring.config.activate.on-profile: qa
logging.level.root: info
logging.config: classpath:log4j2-qa.xml

---
# prod
spring.profiles: prod
spring.config.activate.on-profile: prod
management.endpoint.metrics.enabled: false
management.endpoint.env.enabled: false
management.endpoint.configprops.enabled: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.prebid.cache.builders;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.prebid.cache.exceptions.BadRequestException;
import org.prebid.cache.exceptions.RepositoryException;
import org.prebid.cache.exceptions.ResourceNotFoundException;
import org.prebid.cache.model.Payload;
import org.prebid.cache.model.PayloadWrapper;
import org.prebid.cache.routers.ApiConfig;
import lombok.val;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
Expand All @@ -20,16 +19,18 @@
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Signal;
import reactor.test.StepVerifier;

import java.util.Collections;
import java.util.Date;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import static org.springframework.http.MediaType.*;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8;
import static org.springframework.http.MediaType.APPLICATION_XML;

@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes={PrebidServerResponseBuilder.class, ApiConfig.class})
Expand All @@ -53,10 +54,9 @@ private Mono<ServerResponse> createResponseMono(final ServerRequest request,
}

private void subscribeAndVerify(final Mono<ServerResponse> mono,
final BiConsumer<ServerResponse, Throwable> consumer)
{
mono.doAfterSuccessOrError(consumer)
.subscribe();
Consumer<Signal<ServerResponse>> consumer) {

mono.doOnEach(consumer).subscribe();
StepVerifier.create(mono)
.expectSubscription()
.expectNextMatches(t -> true)
Expand All @@ -66,25 +66,26 @@ private void subscribeAndVerify(final Mono<ServerResponse> mono,

private void verifyServerResponse(MediaType mediaType) {
final var request = MockServerRequest.builder().build();
BiConsumer<ServerResponse, Throwable> consumer = (v, t) -> {
assertEquals(200, v.statusCode().value());
assertTrue(v.headers().containsValue(Collections.singletonList(mediaType.toString())));
final Consumer<Signal<ServerResponse>> consumer = signal -> {
assertTrue(signal.isOnComplete());

final ServerResponse response = signal.get();
assertEquals(200, response.statusCode().value());
assertTrue(response.headers().containsValue(Collections.singletonList(mediaType.toString())));
};

subscribeAndVerify(createResponseMono(request, mediaType), consumer);
}

private void verifyErrorResponse(HttpStatus status) {
final var request = MockServerRequest.builder().build();
BiConsumer<ServerResponse, Throwable> consumer =
(v, t) -> assertEquals(status.value(), v.statusCode().value());
final Consumer<Signal<ServerResponse>> consumer =
signal -> assertEquals(status.value(), signal.get().statusCode().value());

subscribeAndVerify(createErrorMono(request, status), consumer);
}

private Mono<ServerResponse> createErrorMono(final ServerRequest request,
final HttpStatus status)
{
private Mono<ServerResponse> createErrorMono(final ServerRequest request, final HttpStatus status) {
Mono<Exception> mono = Mono.empty();
if (status.equals(HttpStatus.NOT_FOUND)) {
mono = Mono.just(new ResourceNotFoundException("not found"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
abstract class CacheHandlerTests {

void verifyRepositoryError(CacheHandler handler) {
Consumer<Throwable> consumer = (t) -> {
final Consumer<Throwable> consumer = (t) -> {
assertTrue(t instanceof RepositoryException);
};

verifyResultTest(consumer, handler);
}

void verifyJacksonError(CacheHandler handler) {
Consumer<Throwable> consumer = (t) -> {
final Consumer<Throwable> consumer = (t) -> {
assertTrue(t instanceof RequestParsingException);
};

Expand Down
Loading

0 comments on commit 861540a

Please sign in to comment.