Skip to content

Commit 922c0ca

Browse files
committed
Add BlockHound
1 parent cdf8491 commit 922c0ca

File tree

8 files changed

+22
-4
lines changed

8 files changed

+22
-4
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import org.junit.jupiter.api.DisplayName
1111
import org.junit.jupiter.api.Test
1212
import org.springframework.beans.factory.annotation.Autowired
1313

14-
class IndexesMaintenanceTest : TestBase() {
14+
internal class DatabaseStructureStaticAnalysisTest : TestBase() {
15+
1516
@Autowired
1617
private lateinit var checks: List<DatabaseCheckOnHost<out DbObject>>
1718

spring-boot-3-demo-app-reactive/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ dependencies {
4242
testImplementation("io.github.mfvanek:pg-index-health-test-starter")
4343
testImplementation("org.springframework.cloud:spring-cloud-starter-contract-stub-runner")
4444
testImplementation("io.projectreactor:reactor-test")
45+
testImplementation("io.projectreactor.tools:blockhound:1.0.13.RELEASE")
4546
}
4647

4748
tasks {
49+
withType<Test>().all {
50+
jvmArgs("-XX:+AllowRedefinitionToAddDeleteMethods")
51+
}
52+
4853
jacocoTestCoverageVerification {
4954
dependsOn(jacocoTestReport)
5055
violationRules {

spring-boot-3-demo-app-reactive/src/main/java/io/github/mfvanek/spring/boot3/reactive/Application.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99

1010
import org.springframework.boot.SpringApplication;
1111
import org.springframework.boot.autoconfigure.SpringBootApplication;
12+
import reactor.tools.agent.ReactorDebugAgent;
1213

1314
@SpringBootApplication
1415
public class Application {
1516

1617
public static void main(String[] args) {
18+
ReactorDebugAgent.init();
1719
SpringApplication.run(Application.class, args);
1820
}
1921
}

spring-boot-3-demo-app-reactive/src/main/java/io/github/mfvanek/spring/boot3/reactive/service/KafkaSendingService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.springframework.kafka.support.SendResult;
1616
import org.springframework.stereotype.Service;
1717
import reactor.core.publisher.Mono;
18+
import reactor.core.scheduler.Schedulers;
1819

1920
import java.util.UUID;
2021
import javax.annotation.Nonnull;
@@ -32,7 +33,8 @@ public Mono<SendResult<UUID, String>> sendNotification(@Nonnull final String mes
3233
return Mono.deferContextual(contextView -> {
3334
try (MDC.MDCCloseable ignored = MDC.putCloseable("tenant.name", tenantName)) {
3435
log.info("Sending message \"{}\" to Kafka", message);
35-
return Mono.fromFuture(() -> kafkaTemplate.sendDefault(UUID.randomUUID(), message));
36+
return Mono.fromFuture(() -> kafkaTemplate.sendDefault(UUID.randomUUID(), message))
37+
.subscribeOn(Schedulers.boundedElastic());
3638
}
3739
});
3840
}

spring-boot-3-demo-app-reactive/src/main/java/io/github/mfvanek/spring/boot3/reactive/service/PublicApiService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private Mono<CurrentTime> getZonedTimeFromWorldTimeApi() {
5454
.bodyToMono(String.class)
5555
.retryWhen(prepareRetry(zoneName))
5656
.flatMap(this::convert)
57+
.doOnError(err -> log.warn("Received error response", err)) // TODO ???
5758
.onErrorComplete()
5859
.flatMap(Mono::justOrEmpty);
5960
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import static org.assertj.core.api.Assertions.assertThat;
2323

24-
class IndexesMaintenanceTest extends TestBase {
24+
class DatabaseStructureStaticAnalysisTest extends TestBase {
2525

2626
@Autowired
2727
private List<DatabaseCheckOnHost<? extends DbObject>> checks;

spring-boot-3-demo-app-reactive/src/test/java/io/github/mfvanek/spring/boot3/reactive/support/TestBase.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.github.mfvanek.spring.boot3.reactive.service.dto.CurrentTime;
1313
import io.github.mfvanek.spring.boot3.reactive.service.dto.ParsedDateTime;
1414
import lombok.SneakyThrows;
15+
import org.junit.jupiter.api.BeforeAll;
1516
import org.junit.jupiter.api.BeforeEach;
1617
import org.springframework.beans.factory.annotation.Autowired;
1718
import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
@@ -22,6 +23,7 @@
2223
import org.springframework.test.context.ActiveProfiles;
2324
import org.springframework.test.context.ContextConfiguration;
2425
import org.springframework.test.web.reactive.server.WebTestClient;
26+
import reactor.blockhound.BlockHound;
2527

2628
import java.time.Clock;
2729
import java.util.TimeZone;
@@ -51,6 +53,11 @@ public abstract class TestBase {
5153
@Autowired
5254
protected NamedParameterJdbcTemplate namedParameterJdbcTemplate;
5355

56+
@BeforeAll
57+
static void initBlockHound() {
58+
BlockHound.install();
59+
}
60+
5461
@BeforeEach
5562
void resetExternalMocks() {
5663
WireMock.resetAllRequests();

spring-boot-3-demo-app/src/test/java/io/github/mfvanek/spring/boot3/test/IndexesMaintenanceTest.java renamed to spring-boot-3-demo-app/src/test/java/io/github/mfvanek/spring/boot3/test/DatabaseStructureStaticAnalysisTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import static org.assertj.core.api.Assertions.assertThat;
2323

24-
class IndexesMaintenanceTest extends TestBase {
24+
class DatabaseStructureStaticAnalysisTest extends TestBase {
2525

2626
@Autowired
2727
private List<DatabaseCheckOnHost<? extends DbObject>> checks;

0 commit comments

Comments
 (0)