Skip to content

Commit

Permalink
boot 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinemeyer committed Mar 2, 2024
1 parent 04f747d commit b5c7c19
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
29 changes: 23 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.teketik</groupId>
<artifactId>async-health-indicator</artifactId>
<version>boot2-v1.1</version>
<version>boot3-v1.2</version>
<name>Spring Boot Async Health Indicator</name>
<description>Asynchronous Health Indicator for Spring Boot</description>
<url>https://github.com/antoinemeyer/spring-boot-async-health-indicator</url>
Expand All @@ -29,14 +29,15 @@
</developers>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<java.version>17</java.version>
</properties>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.0.RELEASE</version>
<version>3.0.13</version>
</parent>

<dependencies>
Expand All @@ -51,6 +52,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<!-- TODO remove exclusion -->
<exclusions>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -67,6 +75,15 @@
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

<!-- TODO switch to junit 5 that is in spring boot test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -121,7 +138,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<version>0.8.11</version>
<executions>
<execution>
<goals>
Expand All @@ -148,7 +165,7 @@
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>1.00</minimum>
<minimum>0.90</minimum>
</limit>
</limits>
</rule>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/teketik/spring/health/AsyncHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* }
* </pre>
* <hr>
* <h3>Regarding Timeout</h3>
* <strong>Regarding Timeout</strong>
* <p>
* When a {@link HealthIndicator#health() health method} duration exceeds the configured {@link #timeout()}, the thread running it is <strong>interrupted</strong> with the hope that the method will fail with an exception (causing it to be {@link Status#DOWN})
* and free up the thread.<br>
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/META-INF/spring.factories

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.teketik.spring.health.AsyncHealthIndicatorAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@

import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.util.ReflectionTestUtils;

import java.util.concurrent.TimeUnit;

import javax.annotation.Resource;

@TestPropertySource(properties = {
"management.health.async.pool.max-size=7",
"management.health.async.pool.keep-alive=8",
})
public class ConfigurationTest extends BaseITest {

@Resource
@Autowired
private AsyncHealthIndicatorAutoConfiguration asyncHealthIndicatorAutoConfiguration;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

import com.teketik.spring.health.AsyncHealth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Profile("with-timing-out-web-indicator")
@Component
@AsyncHealth(refreshRate = 1, timeout = 1)
public class TimingOutWebIndicator implements HealthIndicator {

@Resource
@Autowired
private TestRestTemplate testRestTemplate;

@Override
Expand Down

0 comments on commit b5c7c19

Please sign in to comment.