Skip to content

Commit e10342e

Browse files
authored
Merge pull request #23 from brand-dot-dev/release-please--branches--main--changes--next
release: 0.1.0-alpha.21
2 parents ea991ef + f2ab9a1 commit e10342e

19 files changed

Lines changed: 1381 additions & 31 deletions

File tree

.release-please-manifest.json

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

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 12
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-4eb121d211177902ec0685d8829af778dbc02a21df03362e8675a8bcb4ca10a8.yml
3-
openapi_spec_hash: b10e8626e812050d8d0664b5373d7fe4
4-
config_hash: 86160e220c81f47769a71c9343e486d8
1+
configured_endpoints: 13
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-f69782c2c4296df9db6b41a3a7359a9e4910f59e34901b9f0e8045cec3f9ca69.yml
3+
openapi_spec_hash: f06c3956a6fc7e57614b120910339747
4+
config_hash: 6aaf0fe6f8877c9c5d9af95597123cb4

CHANGELOG.md

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

3+
## 0.1.0-alpha.21 (2025-11-29)
4+
5+
Full Changelog: [v0.1.0-alpha.20...v0.1.0-alpha.21](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.20...v0.1.0-alpha.21)
6+
7+
### Features
8+
9+
* **api:** api update ([9bad26d](https://github.com/brand-dot-dev/java-sdk/commit/9bad26d65fb93869378c3232c8b150a27dbcefad))
10+
* **api:** manual updates ([b1fa758](https://github.com/brand-dot-dev/java-sdk/commit/b1fa7588dfa34da8ceb683ae9f917a1418a1b9ac))
11+
12+
13+
### Bug Fixes
14+
15+
* **client:** cancel okhttp call when future cancelled ([107ac59](https://github.com/brand-dot-dev/java-sdk/commit/107ac59dfd51ae137eab042acbeae536acdc0525))
16+
317
## 0.1.0-alpha.20 (2025-11-24)
418

519
Full Changelog: [v0.1.0-alpha.19...v0.1.0-alpha.20](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.19...v0.1.0-alpha.20)

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.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.20)
6-
[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.20/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.20)
5+
[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.21)
6+
[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.21/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.21)
77

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

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

1414
<!-- x-release-please-start-version -->
1515

16-
The REST API documentation can be found on [docs.brand.dev](https://docs.brand.dev/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.20).
16+
The REST API documentation can be found on [docs.brand.dev](https://docs.brand.dev/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.21).
1717

1818
<!-- x-release-please-end -->
1919

@@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.brand.dev](https://docs.brand.d
2424
### Gradle
2525

2626
```kotlin
27-
implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.20")
27+
implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.21")
2828
```
2929

3030
### Maven
@@ -33,7 +33,7 @@ implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.20")
3333
<dependency>
3434
<groupId>com.branddev.api</groupId>
3535
<artifactId>brand-dev-java</artifactId>
36-
<version>0.1.0-alpha.20</version>
36+
<version>0.1.0-alpha.21</version>
3737
</dependency>
3838
```
3939

brand-dev-java-client-okhttp/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ dependencies {
1111

1212
testImplementation(kotlin("test"))
1313
testImplementation("org.assertj:assertj-core:3.25.3")
14+
testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
1415
}

brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import java.io.IOException
1313
import java.io.InputStream
1414
import java.net.Proxy
1515
import java.time.Duration
16+
import java.util.concurrent.CancellationException
1617
import java.util.concurrent.CompletableFuture
1718
import javax.net.ssl.HostnameVerifier
1819
import javax.net.ssl.SSLSocketFactory
@@ -29,8 +30,8 @@ import okhttp3.Response
2930
import okhttp3.logging.HttpLoggingInterceptor
3031
import okio.BufferedSink
3132

32-
class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) :
33-
HttpClient {
33+
class OkHttpClient
34+
private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient {
3435

3536
override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
3637
val call = newCall(request, requestOptions)
@@ -50,20 +51,25 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
5051
): CompletableFuture<HttpResponse> {
5152
val future = CompletableFuture<HttpResponse>()
5253

53-
request.body?.run { future.whenComplete { _, _ -> close() } }
54-
55-
newCall(request, requestOptions)
56-
.enqueue(
57-
object : Callback {
58-
override fun onResponse(call: Call, response: Response) {
59-
future.complete(response.toResponse())
60-
}
54+
val call = newCall(request, requestOptions)
55+
call.enqueue(
56+
object : Callback {
57+
override fun onResponse(call: Call, response: Response) {
58+
future.complete(response.toResponse())
59+
}
6160

62-
override fun onFailure(call: Call, e: IOException) {
63-
future.completeExceptionally(BrandDevIoException("Request failed", e))
64-
}
61+
override fun onFailure(call: Call, e: IOException) {
62+
future.completeExceptionally(BrandDevIoException("Request failed", e))
6563
}
66-
)
64+
}
65+
)
66+
67+
future.whenComplete { _, e ->
68+
if (e is CancellationException) {
69+
call.cancel()
70+
}
71+
request.body?.close()
72+
}
6773

6874
return future
6975
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.branddev.api.client.okhttp
2+
3+
import com.branddev.api.core.http.HttpMethod
4+
import com.branddev.api.core.http.HttpRequest
5+
import com.github.tomakehurst.wiremock.client.WireMock.*
6+
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo
7+
import com.github.tomakehurst.wiremock.junit5.WireMockTest
8+
import org.assertj.core.api.Assertions.assertThat
9+
import org.junit.jupiter.api.BeforeEach
10+
import org.junit.jupiter.api.Test
11+
import org.junit.jupiter.api.parallel.ResourceLock
12+
13+
@WireMockTest
14+
@ResourceLock("https://github.com/wiremock/wiremock/issues/169")
15+
internal class OkHttpClientTest {
16+
17+
private lateinit var baseUrl: String
18+
private lateinit var httpClient: OkHttpClient
19+
20+
@BeforeEach
21+
fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) {
22+
baseUrl = wmRuntimeInfo.httpBaseUrl
23+
httpClient = OkHttpClient.builder().build()
24+
}
25+
26+
@Test
27+
fun executeAsync_whenFutureCancelled_cancelsUnderlyingCall() {
28+
stubFor(post(urlPathEqualTo("/something")).willReturn(ok()))
29+
val responseFuture =
30+
httpClient.executeAsync(
31+
HttpRequest.builder()
32+
.method(HttpMethod.POST)
33+
.baseUrl(baseUrl)
34+
.addPathSegment("something")
35+
.build()
36+
)
37+
val call = httpClient.okHttpClient.dispatcher.runningCalls().single()
38+
39+
responseFuture.cancel(false)
40+
41+
// Should have cancelled the underlying call
42+
assertThat(call.isCanceled()).isTrue()
43+
}
44+
}

0 commit comments

Comments
 (0)