Skip to content

Commit c8ab616

Browse files
authored
Merge pull request #17 from brand-dot-dev/release-please--branches--main--changes--next
release: 0.1.0-alpha.15
2 parents 61a7209 + 7119039 commit c8ab616

26 files changed

Lines changed: 253 additions & 53 deletions

.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.14"
2+
".": "0.1.0-alpha.15"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-558cea4d1e47f7f79e5a42b1113401d9488399f96ce57000488ba82eefc74119.yml
3-
openapi_spec_hash: 576db82fb9e7648107687ee308db7eae
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-ace647670dd24a6335738fb26360272dd0764b0f402e0186df0e92ecd0881c13.yml
3+
openapi_spec_hash: c21512e10bd012cd347bb4afff7da9ae
44
config_hash: 4e76a07aea49753a61313dcd8c10fb0f

CHANGELOG.md

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

3+
## 0.1.0-alpha.15 (2025-09-26)
4+
5+
Full Changelog: [v0.1.0-alpha.14...v0.1.0-alpha.15](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.14...v0.1.0-alpha.15)
6+
7+
### Features
8+
9+
* **api:** api update ([aac4e9e](https://github.com/brand-dot-dev/java-sdk/commit/aac4e9e863a225e8d0ea9bac88addbf8fc588894))
10+
* **client:** expose sleeper option ([ae2f570](https://github.com/brand-dot-dev/java-sdk/commit/ae2f570de5403c9e4387c3a19474de25e0389d64))
11+
12+
13+
### Bug Fixes
14+
15+
* **client:** deserialization of empty objects ([fac2a8c](https://github.com/brand-dot-dev/java-sdk/commit/fac2a8c36227803782d90709dda826adc638bfa0))
16+
* **client:** ensure single timer is created per client ([ae2f570](https://github.com/brand-dot-dev/java-sdk/commit/ae2f570de5403c9e4387c3a19474de25e0389d64))
17+
* **client:** incorrect `getPackageVersion` impl ([e63e7b9](https://github.com/brand-dot-dev/java-sdk/commit/e63e7b99e34764bd21c8fbb95b1fa8f1b54f4163))
18+
19+
20+
### Chores
21+
22+
* **internal:** codegen related update ([4b5343e](https://github.com/brand-dot-dev/java-sdk/commit/4b5343efe7d87afec1f527b0dc1583efa310bc74))
23+
324
## 0.1.0-alpha.14 (2025-09-14)
425

526
Full Changelog: [v0.1.0-alpha.13...v0.1.0-alpha.14](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.13...v0.1.0-alpha.14)

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.14)
6-
[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.14/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.14)
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.15)
6+
[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.15/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.15)
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.14).
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.15).
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.14")
27+
implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.15")
2828
```
2929

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

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.branddev.api.client.okhttp
55
import com.branddev.api.client.BrandDevClient
66
import com.branddev.api.client.BrandDevClientImpl
77
import com.branddev.api.core.ClientOptions
8+
import com.branddev.api.core.Sleeper
89
import com.branddev.api.core.Timeout
910
import com.branddev.api.core.http.Headers
1011
import com.branddev.api.core.http.HttpClient
@@ -120,6 +121,17 @@ class BrandDevOkHttpClient private constructor() {
120121
*/
121122
fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) }
122123

124+
/**
125+
* The interface to use for delaying execution, like during retries.
126+
*
127+
* This is primarily useful for using fake delays in tests.
128+
*
129+
* Defaults to real execution delays.
130+
*
131+
* This class takes ownership of the sleeper and closes it when closed.
132+
*/
133+
fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) }
134+
123135
/**
124136
* The clock to use for operations that require timing, like retries.
125137
*

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.branddev.api.client.okhttp
55
import com.branddev.api.client.BrandDevClientAsync
66
import com.branddev.api.client.BrandDevClientAsyncImpl
77
import com.branddev.api.core.ClientOptions
8+
import com.branddev.api.core.Sleeper
89
import com.branddev.api.core.Timeout
910
import com.branddev.api.core.http.Headers
1011
import com.branddev.api.core.http.HttpClient
@@ -120,6 +121,17 @@ class BrandDevOkHttpClientAsync private constructor() {
120121
*/
121122
fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) }
122123

124+
/**
125+
* The interface to use for delaying execution, like during retries.
126+
*
127+
* This is primarily useful for using fake delays in tests.
128+
*
129+
* Defaults to real execution delays.
130+
*
131+
* This class takes ownership of the sleeper and closes it when closed.
132+
*/
133+
fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) }
134+
123135
/**
124136
* The clock to use for operations that require timing, like retries.
125137
*

brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ private constructor(
4040
* needs to be overridden.
4141
*/
4242
@get:JvmName("jsonMapper") val jsonMapper: JsonMapper,
43+
/**
44+
* The interface to use for delaying execution, like during retries.
45+
*
46+
* This is primarily useful for using fake delays in tests.
47+
*
48+
* Defaults to real execution delays.
49+
*
50+
* This class takes ownership of the sleeper and closes it when closed.
51+
*/
52+
@get:JvmName("sleeper") val sleeper: Sleeper,
4353
/**
4454
* The clock to use for operations that require timing, like retries.
4555
*
@@ -130,6 +140,7 @@ private constructor(
130140
private var httpClient: HttpClient? = null
131141
private var checkJacksonVersionCompatibility: Boolean = true
132142
private var jsonMapper: JsonMapper = jsonMapper()
143+
private var sleeper: Sleeper? = null
133144
private var clock: Clock = Clock.systemUTC()
134145
private var baseUrl: String? = null
135146
private var headers: Headers.Builder = Headers.builder()
@@ -144,6 +155,7 @@ private constructor(
144155
httpClient = clientOptions.originalHttpClient
145156
checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility
146157
jsonMapper = clientOptions.jsonMapper
158+
sleeper = clientOptions.sleeper
147159
clock = clientOptions.clock
148160
baseUrl = clientOptions.baseUrl
149161
headers = clientOptions.headers.toBuilder()
@@ -184,6 +196,17 @@ private constructor(
184196
*/
185197
fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper }
186198

199+
/**
200+
* The interface to use for delaying execution, like during retries.
201+
*
202+
* This is primarily useful for using fake delays in tests.
203+
*
204+
* Defaults to real execution delays.
205+
*
206+
* This class takes ownership of the sleeper and closes it when closed.
207+
*/
208+
fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) }
209+
187210
/**
188211
* The clock to use for operations that require timing, like retries.
189212
*
@@ -367,6 +390,7 @@ private constructor(
367390
*/
368391
fun build(): ClientOptions {
369392
val httpClient = checkRequired("httpClient", httpClient)
393+
val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper())
370394
val apiKey = checkRequired("apiKey", apiKey)
371395

372396
val headers = Headers.builder()
@@ -390,11 +414,13 @@ private constructor(
390414
httpClient,
391415
RetryingHttpClient.builder()
392416
.httpClient(httpClient)
417+
.sleeper(sleeper)
393418
.clock(clock)
394419
.maxRetries(maxRetries)
395420
.build(),
396421
checkJacksonVersionCompatibility,
397422
jsonMapper,
423+
sleeper,
398424
clock,
399425
baseUrl,
400426
headers.build(),
@@ -419,5 +445,6 @@ private constructor(
419445
*/
420446
fun close() {
421447
httpClient.close()
448+
sleeper.close()
422449
}
423450
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.branddev.api.core
2+
3+
import java.time.Duration
4+
import java.util.Timer
5+
import java.util.TimerTask
6+
import java.util.concurrent.CompletableFuture
7+
8+
class DefaultSleeper : Sleeper {
9+
10+
private val timer = Timer("DefaultSleeper", true)
11+
12+
override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis())
13+
14+
override fun sleepAsync(duration: Duration): CompletableFuture<Void> {
15+
val future = CompletableFuture<Void>()
16+
timer.schedule(
17+
object : TimerTask() {
18+
override fun run() {
19+
future.complete(null)
20+
}
21+
},
22+
duration.toMillis(),
23+
)
24+
return future
25+
}
26+
27+
override fun close() = timer.cancel()
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.branddev.api.core
2+
3+
import java.time.Duration
4+
import java.util.concurrent.CompletableFuture
5+
6+
/**
7+
* A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable.
8+
*
9+
* This class ensures the [Sleeper] is closed even if the user forgets to do it.
10+
*/
11+
internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper {
12+
13+
init {
14+
closeWhenPhantomReachable(this, sleeper)
15+
}
16+
17+
override fun sleep(duration: Duration) = sleeper.sleep(duration)
18+
19+
override fun sleepAsync(duration: Duration): CompletableFuture<Void> =
20+
sleeper.sleepAsync(duration)
21+
22+
override fun close() = sleeper.close()
23+
}

brand-dev-java-core/src/main/kotlin/com/branddev/api/core/Properties.kt

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

33
package com.branddev.api.core
44

5-
import java.util.Properties
5+
import com.branddev.api.client.BrandDevClient
66

77
fun getOsArch(): String {
88
val osArch = System.getProperty("os.arch")
@@ -16,7 +16,7 @@ fun getOsArch(): String {
1616
"x86_64" -> "x64"
1717
"arm" -> "arm"
1818
"aarch64" -> "arm64"
19-
else -> "other:${osArch}"
19+
else -> "other:$osArch"
2020
}
2121
}
2222

@@ -30,13 +30,13 @@ fun getOsName(): String {
3030
osName.startsWith("Linux") -> "Linux"
3131
osName.startsWith("Mac OS") -> "MacOS"
3232
osName.startsWith("Windows") -> "Windows"
33-
else -> "Other:${osName}"
33+
else -> "Other:$osName"
3434
}
3535
}
3636

3737
fun getOsVersion(): String = System.getProperty("os.version", "unknown")
3838

3939
fun getPackageVersion(): String =
40-
Properties::class.java.`package`.implementationVersion ?: "unknown"
40+
BrandDevClient::class.java.`package`.implementationVersion ?: "unknown"
4141

4242
fun getJavaVersion(): String = System.getProperty("java.version", "unknown")

0 commit comments

Comments
 (0)