diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index f1401f154..bb57c8a49 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.290.0"
+ ".": "0.291.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index be347cd13..fd1dcd264 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 215
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-ce8ac7ef645ad6089e9730ae2b44492a6a958a2abcc8bb50130c5ebd7ba1a390.yml
-openapi_spec_hash: 90a27266ac1eeab3464f6825d8fd8650
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-3db2c20491e1218b324938f048e489f800270f608505ac2293f66d1691294f4f.yml
+openapi_spec_hash: d821b4d13c8fc8257b34a544515e91f7
config_hash: 0b0a2503208283b283fc5bc6df6a07a5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 26df191a4..8937371fa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog
+## 0.291.0 (2025-08-20)
+
+Full Changelog: [v0.290.0...v0.291.0](https://github.com/Increase/increase-java/compare/v0.290.0...v0.291.0)
+
+### Features
+
+* **api:** api update ([b36e5a2](https://github.com/Increase/increase-java/commit/b36e5a298e285fa6e7817b5b499498fde431f662))
+
+
+### Chores
+
+* **client:** refactor closing / shutdown ([d60429a](https://github.com/Increase/increase-java/commit/d60429a7493712e18d4fdd9f9ef3764b277dced6))
+* **internal:** support running formatters directly ([320f9b0](https://github.com/Increase/increase-java/commit/320f9b0aeffa6ef5328d578e725d6dddb5d034c0))
+
## 0.290.0 (2025-08-20)
Full Changelog: [v0.289.1...v0.290.0](https://github.com/Increase/increase-java/compare/v0.289.1...v0.290.0)
diff --git a/README.md b/README.md
index da74a8c91..d3cbbeec8 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.290.0)
-[](https://javadoc.io/doc/com.increase.api/increase-java/0.290.0)
+[](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.291.0)
+[](https://javadoc.io/doc/com.increase.api/increase-java/0.291.0)
@@ -13,7 +13,7 @@ The Increase Java SDK is similar to the Increase Kotlin SDK but with minor diffe
-The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.290.0).
+The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.291.0).
@@ -24,7 +24,7 @@ The REST API documentation can be found on [increase.com](https://increase.com/d
### Gradle
```kotlin
-implementation("com.increase.api:increase-java:0.290.0")
+implementation("com.increase.api:increase-java:0.291.0")
```
### Maven
@@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.290.0")
com.increase.api
increase-java
- 0.290.0
+ 0.291.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index a68533e5e..1bc75e736 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.increase.api"
- version = "0.290.0" // x-release-please-version
+ version = "0.291.0" // x-release-please-version
}
subprojects {
diff --git a/increase-java-client-okhttp/src/main/kotlin/com/increase/api/client/okhttp/IncreaseOkHttpClient.kt b/increase-java-client-okhttp/src/main/kotlin/com/increase/api/client/okhttp/IncreaseOkHttpClient.kt
index 5e0da4ab6..e39a18d6e 100644
--- a/increase-java-client-okhttp/src/main/kotlin/com/increase/api/client/okhttp/IncreaseOkHttpClient.kt
+++ b/increase-java-client-okhttp/src/main/kotlin/com/increase/api/client/okhttp/IncreaseOkHttpClient.kt
@@ -126,6 +126,8 @@ class IncreaseOkHttpClient private constructor() {
* The executor to use for running [AsyncStreamResponse.Handler] callbacks.
*
* Defaults to a dedicated cached thread pool.
+ *
+ * This class takes ownership of the executor and shuts it down, if possible, when closed.
*/
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
clientOptions.streamHandlerExecutor(streamHandlerExecutor)
diff --git a/increase-java-client-okhttp/src/main/kotlin/com/increase/api/client/okhttp/IncreaseOkHttpClientAsync.kt b/increase-java-client-okhttp/src/main/kotlin/com/increase/api/client/okhttp/IncreaseOkHttpClientAsync.kt
index 21a89bae1..d4c0b7a53 100644
--- a/increase-java-client-okhttp/src/main/kotlin/com/increase/api/client/okhttp/IncreaseOkHttpClientAsync.kt
+++ b/increase-java-client-okhttp/src/main/kotlin/com/increase/api/client/okhttp/IncreaseOkHttpClientAsync.kt
@@ -126,6 +126,8 @@ class IncreaseOkHttpClientAsync private constructor() {
* The executor to use for running [AsyncStreamResponse.Handler] callbacks.
*
* Defaults to a dedicated cached thread pool.
+ *
+ * This class takes ownership of the executor and shuts it down, if possible, when closed.
*/
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
clientOptions.streamHandlerExecutor(streamHandlerExecutor)
diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt
index 1b70f5b20..24b0ae717 100644
--- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt
+++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt
@@ -478,7 +478,7 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa
override fun simulations(): SimulationServiceAsync = simulations
- override fun close() = clientOptions.httpClient.close()
+ override fun close() = clientOptions.close()
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
IncreaseClientAsync.WithRawResponse {
diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt
index 7546fa83d..5a524ea23 100644
--- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt
+++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt
@@ -462,7 +462,7 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli
override fun simulations(): SimulationService = simulations
- override fun close() = clientOptions.httpClient.close()
+ override fun close() = clientOptions.close()
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
IncreaseClient.WithRawResponse {
diff --git a/increase-java-core/src/main/kotlin/com/increase/api/core/ClientOptions.kt b/increase-java-core/src/main/kotlin/com/increase/api/core/ClientOptions.kt
index a4837d9f5..9cb09226b 100644
--- a/increase-java-core/src/main/kotlin/com/increase/api/core/ClientOptions.kt
+++ b/increase-java-core/src/main/kotlin/com/increase/api/core/ClientOptions.kt
@@ -13,6 +13,7 @@ import java.time.Clock
import java.time.Duration
import java.util.Optional
import java.util.concurrent.Executor
+import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicLong
@@ -26,6 +27,8 @@ private constructor(
* The HTTP client to use in the SDK.
*
* Use the one published in `increase-java-client-okhttp` or implement your own.
+ *
+ * This class takes ownership of the client and closes it when closed.
*/
@get:JvmName("httpClient") val httpClient: HttpClient,
/**
@@ -47,6 +50,8 @@ private constructor(
* The executor to use for running [AsyncStreamResponse.Handler] callbacks.
*
* Defaults to a dedicated cached thread pool.
+ *
+ * This class takes ownership of the executor and shuts it down, if possible, when closed.
*/
@get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor,
/**
@@ -179,6 +184,8 @@ private constructor(
* The HTTP client to use in the SDK.
*
* Use the one published in `increase-java-client-okhttp` or implement your own.
+ *
+ * This class takes ownership of the client and closes it when closed.
*/
fun httpClient(httpClient: HttpClient) = apply {
this.httpClient = PhantomReachableClosingHttpClient(httpClient)
@@ -207,9 +214,14 @@ private constructor(
* The executor to use for running [AsyncStreamResponse.Handler] callbacks.
*
* Defaults to a dedicated cached thread pool.
+ *
+ * This class takes ownership of the executor and shuts it down, if possible, when closed.
*/
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
- this.streamHandlerExecutor = streamHandlerExecutor
+ this.streamHandlerExecutor =
+ if (streamHandlerExecutor is ExecutorService)
+ PhantomReachableExecutorService(streamHandlerExecutor)
+ else streamHandlerExecutor
}
/**
@@ -467,4 +479,19 @@ private constructor(
)
}
}
+
+ /**
+ * Closes these client options, relinquishing any underlying resources.
+ *
+ * This is purposefully not inherited from [AutoCloseable] because the client options are
+ * long-lived and usually should not be synchronously closed via try-with-resources.
+ *
+ * It's also usually not necessary to call this method at all. the default client automatically
+ * releases threads and connections if they remain idle, but if you are writing an application
+ * that needs to aggressively release unused resources, then you may call this method.
+ */
+ fun close() {
+ httpClient.close()
+ (streamHandlerExecutor as? ExecutorService)?.shutdown()
+ }
}
diff --git a/increase-java-core/src/main/kotlin/com/increase/api/core/PhantomReachableExecutorService.kt b/increase-java-core/src/main/kotlin/com/increase/api/core/PhantomReachableExecutorService.kt
new file mode 100644
index 000000000..c20bdec9e
--- /dev/null
+++ b/increase-java-core/src/main/kotlin/com/increase/api/core/PhantomReachableExecutorService.kt
@@ -0,0 +1,58 @@
+package com.increase.api.core
+
+import java.util.concurrent.Callable
+import java.util.concurrent.ExecutorService
+import java.util.concurrent.Future
+import java.util.concurrent.TimeUnit
+
+/**
+ * A delegating wrapper around an [ExecutorService] that shuts it down once it's only phantom
+ * reachable.
+ *
+ * This class ensures the [ExecutorService] is shut down even if the user forgets to do it.
+ */
+internal class PhantomReachableExecutorService(private val executorService: ExecutorService) :
+ ExecutorService {
+ init {
+ closeWhenPhantomReachable(this) { executorService.shutdown() }
+ }
+
+ override fun execute(command: Runnable) = executorService.execute(command)
+
+ override fun shutdown() = executorService.shutdown()
+
+ override fun shutdownNow(): MutableList = executorService.shutdownNow()
+
+ override fun isShutdown(): Boolean = executorService.isShutdown
+
+ override fun isTerminated(): Boolean = executorService.isTerminated
+
+ override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean =
+ executorService.awaitTermination(timeout, unit)
+
+ override fun submit(task: Callable): Future = executorService.submit(task)
+
+ override fun submit(task: Runnable, result: T): Future =
+ executorService.submit(task, result)
+
+ override fun submit(task: Runnable): Future<*> = executorService.submit(task)
+
+ override fun invokeAll(
+ tasks: MutableCollection>
+ ): MutableList> = executorService.invokeAll(tasks)
+
+ override fun invokeAll(
+ tasks: MutableCollection>,
+ timeout: Long,
+ unit: TimeUnit,
+ ): MutableList> = executorService.invokeAll(tasks, timeout, unit)
+
+ override fun invokeAny(tasks: MutableCollection>): T =
+ executorService.invokeAny(tasks)
+
+ override fun invokeAny(
+ tasks: MutableCollection>,
+ timeout: Long,
+ unit: TimeUnit,
+ ): T = executorService.invokeAny(tasks, timeout, unit)
+}
diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/realtimepaymentstransfers/RealTimePaymentsTransferApproveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/realtimepaymentstransfers/RealTimePaymentsTransferApproveParams.kt
index 3d88e404a..5b768b910 100644
--- a/increase-java-core/src/main/kotlin/com/increase/api/models/realtimepaymentstransfers/RealTimePaymentsTransferApproveParams.kt
+++ b/increase-java-core/src/main/kotlin/com/increase/api/models/realtimepaymentstransfers/RealTimePaymentsTransferApproveParams.kt
@@ -11,7 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/** Approves an Real-Time Payments Transfer in a pending_approval state. */
+/** Approves a Real-Time Payments Transfer in a pending_approval state. */
class RealTimePaymentsTransferApproveParams
private constructor(
private val realTimePaymentsTransferId: String?,
diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/realtimepaymentstransfers/RealTimePaymentsTransferCancelParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/realtimepaymentstransfers/RealTimePaymentsTransferCancelParams.kt
index add0c32be..e57886bf0 100644
--- a/increase-java-core/src/main/kotlin/com/increase/api/models/realtimepaymentstransfers/RealTimePaymentsTransferCancelParams.kt
+++ b/increase-java-core/src/main/kotlin/com/increase/api/models/realtimepaymentstransfers/RealTimePaymentsTransferCancelParams.kt
@@ -11,7 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/** Cancels an Real-Time Payments Transfer in a pending_approval state. */
+/** Cancels a Real-Time Payments Transfer in a pending_approval state. */
class RealTimePaymentsTransferCancelParams
private constructor(
private val realTimePaymentsTransferId: String?,
diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/RealTimePaymentsTransferServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/RealTimePaymentsTransferServiceAsync.kt
index d5a63200a..0ed14add4 100644
--- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/RealTimePaymentsTransferServiceAsync.kt
+++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/RealTimePaymentsTransferServiceAsync.kt
@@ -108,7 +108,7 @@ interface RealTimePaymentsTransferServiceAsync {
): CompletableFuture =
list(RealTimePaymentsTransferListParams.none(), requestOptions)
- /** Approves an Real-Time Payments Transfer in a pending_approval state. */
+ /** Approves a Real-Time Payments Transfer in a pending_approval state. */
fun approve(realTimePaymentsTransferId: String): CompletableFuture =
approve(realTimePaymentsTransferId, RealTimePaymentsTransferApproveParams.none())
@@ -153,7 +153,7 @@ interface RealTimePaymentsTransferServiceAsync {
requestOptions,
)
- /** Cancels an Real-Time Payments Transfer in a pending_approval state. */
+ /** Cancels a Real-Time Payments Transfer in a pending_approval state. */
fun cancel(realTimePaymentsTransferId: String): CompletableFuture =
cancel(realTimePaymentsTransferId, RealTimePaymentsTransferCancelParams.none())
diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/RealTimePaymentsTransferService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/RealTimePaymentsTransferService.kt
index 72658241d..6c94bd631 100644
--- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/RealTimePaymentsTransferService.kt
+++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/RealTimePaymentsTransferService.kt
@@ -102,7 +102,7 @@ interface RealTimePaymentsTransferService {
fun list(requestOptions: RequestOptions): RealTimePaymentsTransferListPage =
list(RealTimePaymentsTransferListParams.none(), requestOptions)
- /** Approves an Real-Time Payments Transfer in a pending_approval state. */
+ /** Approves a Real-Time Payments Transfer in a pending_approval state. */
fun approve(realTimePaymentsTransferId: String): RealTimePaymentsTransfer =
approve(realTimePaymentsTransferId, RealTimePaymentsTransferApproveParams.none())
@@ -145,7 +145,7 @@ interface RealTimePaymentsTransferService {
requestOptions,
)
- /** Cancels an Real-Time Payments Transfer in a pending_approval state. */
+ /** Cancels a Real-Time Payments Transfer in a pending_approval state. */
fun cancel(realTimePaymentsTransferId: String): RealTimePaymentsTransfer =
cancel(realTimePaymentsTransferId, RealTimePaymentsTransferCancelParams.none())
diff --git a/scripts/format b/scripts/format
index 7c0be4d57..65db1769a 100755
--- a/scripts/format
+++ b/scripts/format
@@ -4,5 +4,18 @@ set -e
cd "$(dirname "$0")/.."
-echo "==> Running formatters"
-./gradlew format
+if command -v ktfmt &> /dev/null; then
+ echo "==> Running ktfmt"
+ ./scripts/kotlin-format
+else
+ echo "==> Running gradlew formatKotlin"
+ ./gradlew formatKotlin
+fi
+
+if command -v palantir-java-format &> /dev/null; then
+ echo "==> Running palantir-java-format"
+ ./scripts/java-format
+else
+ echo "==> Running gradlew formatJava"
+ ./gradlew formatJava
+fi
diff --git a/scripts/java-format b/scripts/java-format
new file mode 100755
index 000000000..ad5febce9
--- /dev/null
+++ b/scripts/java-format
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -e
+
+cd "$(dirname "$0")/.."
+
+find . -name "*.java" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r palantir-java-format --palantir --replace "$@"
diff --git a/scripts/kotlin-format b/scripts/kotlin-format
new file mode 100755
index 000000000..3b8be9ea9
--- /dev/null
+++ b/scripts/kotlin-format
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -e
+
+cd "$(dirname "$0")/.."
+
+find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@"
diff --git a/scripts/lint b/scripts/lint
index aea8af713..dbc8f7760 100755
--- a/scripts/lint
+++ b/scripts/lint
@@ -5,4 +5,19 @@ set -e
cd "$(dirname "$0")/.."
echo "==> Running lints"
-./gradlew lint
+
+if command -v ktfmt &> /dev/null; then
+ echo "==> Checking ktfmt"
+ ./scripts/kotlin-format --dry-run --set-exit-if-changed
+else
+ echo "==> Running gradlew lintKotlin"
+ ./gradlew lintKotlin
+fi
+
+if command -v palantir-java-format &> /dev/null; then
+ echo "==> Checking palantir-java-format"
+ ./scripts/java-format --dry-run --set-exit-if-changed
+else
+ echo "==> Running gradlew lintJava"
+ ./gradlew lintJava
+fi