forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#40012 from Ladicek/fault-tolerance-6.3.0
Upgrade to SmallRye Fault Tolerance 6.3.0
- Loading branch information
Showing
23 changed files
with
252 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...quarkus/smallrye/faulttolerance/test/asynchronous/additional/AsyncNonBlockingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...java/io/quarkus/smallrye/faulttolerance/test/asynchronous/additional/BlockingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a/io/quarkus/smallrye/faulttolerance/test/asynchronous/additional/NonblockingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rkus/smallrye/faulttolerance/test/asynchronous/noncompat/NoncompatNonblockingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...t/java/io/quarkus/smallrye/faulttolerance/test/retry/when/IsIllegalArgumentException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class IsIllegalArgumentException implements Predicate<Throwable> { | ||
@Override | ||
public boolean test(Throwable throwable) { | ||
return throwable instanceof IllegalArgumentException; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...e/deployment/src/test/java/io/quarkus/smallrye/faulttolerance/test/retry/when/IsNull.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class IsNull implements Predicate<Object> { | ||
@Override | ||
public boolean test(Object o) { | ||
return o == null; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
.../quarkus/smallrye/faulttolerance/test/retry/when/RetryOnAndRetryWhenExceptionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
|
||
import io.smallrye.faulttolerance.api.RetryWhen; | ||
|
||
@ApplicationScoped | ||
public class RetryOnAndRetryWhenExceptionService { | ||
@Retry(retryOn = IllegalStateException.class) | ||
@RetryWhen(exception = IsIllegalArgumentException.class) | ||
public void hello() { | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../io/quarkus/smallrye/faulttolerance/test/retry/when/RetryOnAndRetryWhenExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class RetryOnAndRetryWhenExceptionTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RetryOnAndRetryWhenExceptionService.class, IsIllegalArgumentException.class)) | ||
.assertException(e -> { | ||
assertEquals(DeploymentException.class, e.getClass()); | ||
assertTrue(e.getMessage().contains("Invalid @RetryWhen.exception")); | ||
assertTrue(e.getMessage().contains("must not be combined with @Retry.retryOn")); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...quarkus/smallrye/faulttolerance/test/retry/when/RetryOnClassRetryWhenOnMethodService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
|
||
import io.smallrye.faulttolerance.api.RetryWhen; | ||
|
||
@Dependent | ||
@Retry | ||
public class RetryOnClassRetryWhenOnMethodService { | ||
@RetryWhen | ||
public void hello() { | ||
throw new IllegalArgumentException(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...io/quarkus/smallrye/faulttolerance/test/retry/when/RetryOnClassRetryWhenOnMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import jakarta.enterprise.inject.spi.DefinitionException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class RetryOnClassRetryWhenOnMethodTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RetryOnClassRetryWhenOnMethodService.class)) | ||
.assertException(e -> { | ||
assertEquals(DefinitionException.class, e.getClass()); | ||
assertTrue(e.getMessage().contains("@RetryWhen present")); | ||
assertTrue(e.getMessage().contains("@Retry is missing")); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...quarkus/smallrye/faulttolerance/test/retry/when/RetryOnMethodRetryWhenOnClassService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
|
||
import io.smallrye.faulttolerance.api.RetryWhen; | ||
|
||
@Dependent | ||
@RetryWhen | ||
public class RetryOnMethodRetryWhenOnClassService { | ||
@Retry | ||
public void hello() { | ||
throw new IllegalArgumentException(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...io/quarkus/smallrye/faulttolerance/test/retry/when/RetryOnMethodRetryWhenOnClassTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import jakarta.enterprise.inject.spi.DefinitionException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class RetryOnMethodRetryWhenOnClassTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RetryOnMethodRetryWhenOnClassService.class)) | ||
.assertException(e -> { | ||
assertEquals(DefinitionException.class, e.getClass()); | ||
assertTrue(e.getMessage().contains("@RetryWhen present")); | ||
assertTrue(e.getMessage().contains("@Retry is missing")); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...o/quarkus/smallrye/faulttolerance/test/retry/when/RetryWhenResultAndExceptionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
|
||
import io.smallrye.faulttolerance.api.RetryWhen; | ||
|
||
@ApplicationScoped | ||
public class RetryWhenResultAndExceptionService { | ||
private final AtomicInteger attempts = new AtomicInteger(); | ||
|
||
@Retry | ||
@RetryWhen(result = IsNull.class, exception = IsIllegalArgumentException.class) | ||
public String hello() { | ||
int current = attempts.incrementAndGet(); | ||
if (current == 1) { | ||
return null; | ||
} else if (current == 2) { | ||
throw new IllegalArgumentException(); | ||
} else { | ||
return "hello"; | ||
} | ||
} | ||
|
||
public AtomicInteger getAttempts() { | ||
return attempts; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...a/io/quarkus/smallrye/faulttolerance/test/retry/when/RetryWhenResultAndExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.when; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class RetryWhenResultAndExceptionTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RetryWhenResultAndExceptionService.class, IsNull.class, IsIllegalArgumentException.class)); | ||
|
||
@Inject | ||
RetryWhenResultAndExceptionService service; | ||
|
||
@Test | ||
public void test() { | ||
assertThat(service.hello()).isEqualTo("hello"); | ||
assertThat(service.getAttempts()).hasValue(3); | ||
} | ||
} |
Oops, something went wrong.