-
Notifications
You must be signed in to change notification settings - Fork 32
Add synchronous API methods and Resilience4j configuration support #523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add synchronous API methods and Resilience4j configuration support #523
Conversation
| System.out.println("Asynchronous call time: " + TimeUnit.NANOSECONDS.toMicros(asyncTime) + " microseconds"); | ||
|
|
||
| // Same return type! | ||
| assertTrue(syncResult instanceof CompletableFuture); |
Check warning
Code scanning / CodeQL
Useless type test Warning test
CompletableFuture
CompletableFuture<>
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 17 days ago
To fix the problem, simply remove the unnecessary instanceof checks that test if an object is an instance of its declared type. In this specific case, remove the assertions on lines 175 and 176:
assertTrue(syncResult instanceof CompletableFuture);
assertTrue(asyncResult instanceof CompletableFuture);No replacement is necessary, as both variables are already declared as CompletableFuture<PaymentResponse>, and the remaining comments and outputs explain the differences. Only remove these two lines; do not replace them with other tests, as the type guarantee is enforced by the compiler.
| @@ -172,8 +172,6 @@ | ||
| System.out.println("Asynchronous call time: " + TimeUnit.NANOSECONDS.toMicros(asyncTime) + " microseconds"); | ||
|
|
||
| // Same return type! | ||
| assertTrue(syncResult instanceof CompletableFuture); | ||
| assertTrue(asyncResult instanceof CompletableFuture); | ||
|
|
||
| System.out.println("\nBoth return CompletableFuture<PaymentResponse>"); | ||
| System.out.println("Difference: Synchronous executes HTTP call before returning CompletableFuture"); |
|
|
||
| // Same return type! | ||
| assertTrue(syncResult instanceof CompletableFuture); | ||
| assertTrue(asyncResult instanceof CompletableFuture); |
Check warning
Code scanning / CodeQL
Useless type test Warning test
CompletableFuture
CompletableFuture<>
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 17 days ago
The best way to fix this problem is to remove the instanceof checks entirely. Specifically, the following lines should be deleted:
175: assertTrue(syncResult instanceof CompletableFuture);
176: assertTrue(asyncResult instanceof CompletableFuture);No replacement is needed, nor is any other kind of assertion or code necessary, because the declared types make the implication explicit. This change should only involve file src/test/java/com/checkout/SynchronousAsyncClientComparisonTest.java, affecting lines 175–176. No other code or imports need to be changed or added.
| @@ -172,8 +172,6 @@ | ||
| System.out.println("Asynchronous call time: " + TimeUnit.NANOSECONDS.toMicros(asyncTime) + " microseconds"); | ||
|
|
||
| // Same return type! | ||
| assertTrue(syncResult instanceof CompletableFuture); | ||
| assertTrue(asyncResult instanceof CompletableFuture); | ||
|
|
||
| System.out.println("\nBoth return CompletableFuture<PaymentResponse>"); | ||
| System.out.println("Difference: Synchronous executes HTTP call before returning CompletableFuture"); |
|



This pull request introduces significant enhancements to the SDK's configuration and transport layers, adding support for synchronous API calls and integrating Resilience4j for resilience features like circuit breaking, rate limiting, and retries. It also updates constructors and interfaces to support these new capabilities while maintaining backward compatibility.
Synchronous API support and configuration enhancements
synchronousflag and aResilience4jConfigurationproperty toAbstractCheckoutSdkBuilder, allowing users to configure synchronous behavior and resilience features when building the SDK client. [1] [2]DefaultCheckoutConfigurationandCheckoutConfigurationto support newsynchronousandResilience4jConfigurationoptions, including multiple overloaded constructors for backward compatibility. [1] [2] [3] [4] [5]Synchronous transport and API methods
invokeSync,submitFileSync) inApacheHttpClientTransport, and added logic to wrap calls with Resilience4j decorators if configured.ApiClientandApiClientImplinterfaces/classes with a full set of synchronous HTTP methods (get,post,put,patch,delete,query, etc.), mirroring the existing async API. [1] [2]Resilience4j integration
Build tool update
3.19.2to4.2.2insettings.gradle.