Skip to content

Commit 2d13d84

Browse files
release: 8.3.2 (#481)
* chore(client): refactor closing / shutdown * chore(internal): support running ktfmt directly * release: 8.3.2 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent c2e7865 commit 2d13d84

File tree

10 files changed

+108
-13
lines changed

10 files changed

+108
-13
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "8.3.1"
2+
".": "8.3.2"
33
}

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 8.3.2 (2025-08-20)
4+
5+
Full Changelog: [v8.3.1...v8.3.2](https://github.com/Finch-API/finch-api-kotlin/compare/v8.3.1...v8.3.2)
6+
7+
### Chores
8+
9+
* **client:** refactor closing / shutdown ([b8eab02](https://github.com/Finch-API/finch-api-kotlin/commit/b8eab023ed3e81a9c16de1205f2e8075c4f0cb40))
10+
* **internal:** support running ktfmt directly ([192c9eb](https://github.com/Finch-API/finch-api-kotlin/commit/192c9ebb042f49b7294d0c706049827ed30c2dae))
11+
312
## 8.3.1 (2025-08-14)
413

514
Full Changelog: [v8.3.0...v8.3.1](https://github.com/Finch-API/finch-api-kotlin/compare/v8.3.0...v8.3.1)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<!-- x-release-please-start-version -->
44

5-
[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-kotlin)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-kotlin/8.3.1)
6-
[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-kotlin/8.3.1/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-kotlin/8.3.1)
5+
[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-kotlin)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-kotlin/8.3.2)
6+
[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-kotlin/8.3.2/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-kotlin/8.3.2)
77

88
<!-- x-release-please-end -->
99

@@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/).
1515

1616
<!-- x-release-please-start-version -->
1717

18-
The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-kotlin/8.3.1).
18+
The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-kotlin/8.3.2).
1919

2020
<!-- x-release-please-end -->
2121

@@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.tryfinch.com](https://deve
2626
### Gradle
2727

2828
```kotlin
29-
implementation("com.tryfinch.api:finch-kotlin:8.3.1")
29+
implementation("com.tryfinch.api:finch-kotlin:8.3.2")
3030
```
3131

3232
### Maven
@@ -35,7 +35,7 @@ implementation("com.tryfinch.api:finch-kotlin:8.3.1")
3535
<dependency>
3636
<groupId>com.tryfinch.api</groupId>
3737
<artifactId>finch-kotlin</artifactId>
38-
<version>8.3.1</version>
38+
<version>8.3.2</version>
3939
</dependency>
4040
```
4141

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88

99
allprojects {
1010
group = "com.tryfinch.api"
11-
version = "8.3.1" // x-release-please-version
11+
version = "8.3.2" // x-release-please-version
1212
}
1313

1414
subprojects {

finch-kotlin-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie
121121

122122
override fun connect(): ConnectServiceAsync = connect
123123

124-
override fun close() = clientOptions.httpClient.close()
124+
override fun close() = clientOptions.close()
125125

126126
// Auth helpers:
127127
/** @deprecated use client.accessTokens().create instead */

finch-kotlin-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient {
111111

112112
override fun connect(): ConnectService = connect
113113

114-
override fun close() = clientOptions.httpClient.close()
114+
override fun close() = clientOptions.close()
115115

116116
// auth helpers:
117117
/** @deprecated use client.accessTokens().create instead */

finch-kotlin-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ private constructor(
2020
* The HTTP client to use in the SDK.
2121
*
2222
* Use the one published in `finch-kotlin-client-okhttp` or implement your own.
23+
*
24+
* This class takes ownership of the client and closes it when closed.
2325
*/
2426
val httpClient: HttpClient,
2527
/**
@@ -162,6 +164,8 @@ private constructor(
162164
* The HTTP client to use in the SDK.
163165
*
164166
* Use the one published in `finch-kotlin-client-okhttp` or implement your own.
167+
*
168+
* This class takes ownership of the client and closes it when closed.
165169
*/
166170
fun httpClient(httpClient: HttpClient) = apply {
167171
this.httpClient = PhantomReachableClosingHttpClient(httpClient)
@@ -429,4 +433,18 @@ private constructor(
429433
)
430434
}
431435
}
436+
437+
/**
438+
* Closes these client options, relinquishing any underlying resources.
439+
*
440+
* This is purposefully not inherited from [AutoCloseable] because the client options are
441+
* long-lived and usually should not be synchronously closed via try-with-resources.
442+
*
443+
* It's also usually not necessary to call this method at all. the default client automatically
444+
* releases threads and connections if they remain idle, but if you are writing an application
445+
* that needs to aggressively release unused resources, then you may call this method.
446+
*/
447+
fun close() {
448+
httpClient.close()
449+
}
432450
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.tryfinch.api.core
2+
3+
import java.util.concurrent.Callable
4+
import java.util.concurrent.ExecutorService
5+
import java.util.concurrent.Future
6+
import java.util.concurrent.TimeUnit
7+
8+
/**
9+
* A delegating wrapper around an [ExecutorService] that shuts it down once it's only phantom
10+
* reachable.
11+
*
12+
* This class ensures the [ExecutorService] is shut down even if the user forgets to do it.
13+
*/
14+
internal class PhantomReachableExecutorService(private val executorService: ExecutorService) :
15+
ExecutorService {
16+
init {
17+
closeWhenPhantomReachable(this) { executorService.shutdown() }
18+
}
19+
20+
override fun execute(command: Runnable) = executorService.execute(command)
21+
22+
override fun shutdown() = executorService.shutdown()
23+
24+
override fun shutdownNow(): MutableList<Runnable> = executorService.shutdownNow()
25+
26+
override fun isShutdown(): Boolean = executorService.isShutdown
27+
28+
override fun isTerminated(): Boolean = executorService.isTerminated
29+
30+
override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean =
31+
executorService.awaitTermination(timeout, unit)
32+
33+
override fun <T : Any?> submit(task: Callable<T>): Future<T> = executorService.submit(task)
34+
35+
override fun <T : Any?> submit(task: Runnable, result: T): Future<T> =
36+
executorService.submit(task, result)
37+
38+
override fun submit(task: Runnable): Future<*> = executorService.submit(task)
39+
40+
override fun <T : Any?> invokeAll(
41+
tasks: MutableCollection<out Callable<T>>
42+
): MutableList<Future<T>> = executorService.invokeAll(tasks)
43+
44+
override fun <T : Any?> invokeAll(
45+
tasks: MutableCollection<out Callable<T>>,
46+
timeout: Long,
47+
unit: TimeUnit,
48+
): MutableList<Future<T>> = executorService.invokeAll(tasks, timeout, unit)
49+
50+
override fun <T : Any?> invokeAny(tasks: MutableCollection<out Callable<T>>): T =
51+
executorService.invokeAny(tasks)
52+
53+
override fun <T : Any?> invokeAny(
54+
tasks: MutableCollection<out Callable<T>>,
55+
timeout: Long,
56+
unit: TimeUnit,
57+
): T = executorService.invokeAny(tasks, timeout, unit)
58+
}

scripts/format

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
echo "==> Running formatters"
8-
./gradlew format
7+
if command -v ktfmt &> /dev/null; then
8+
echo "==> Running ktfmt"
9+
find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@"
10+
else
11+
echo "==> Running gradlew format"
12+
./gradlew format
13+
fi

scripts/lint

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
echo "==> Running lints"
8-
./gradlew lint
7+
if command -v ktfmt &> /dev/null; then
8+
echo "==> Checking ktfmt"
9+
./scripts/format --dry-run --set-exit-if-changed
10+
else
11+
echo "==> Running gradlew lint"
12+
./gradlew lint
13+
fi

0 commit comments

Comments
 (0)