Skip to content

Commit 4d388dd

Browse files
Merge pull request #96 from OneBusAway/release-please--branches--main--changes--next
release: 0.1.0-alpha.40
2 parents 3fedbdf + 2dad5cf commit 4d388dd

File tree

14 files changed

+179
-48
lines changed

14 files changed

+179
-48
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-
".": "0.1.0-alpha.39"
2+
".": "0.1.0-alpha.40"
33
}

CHANGELOG.md

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

3+
## 0.1.0-alpha.40 (2025-09-20)
4+
5+
Full Changelog: [v0.1.0-alpha.39...v0.1.0-alpha.40](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.39...v0.1.0-alpha.40)
6+
7+
### Features
8+
9+
* **client:** expose sleeper option ([9c57ef5](https://github.com/OneBusAway/java-sdk/commit/9c57ef569421965bce99ce27f8358c5eb20caa52))
10+
11+
12+
### Bug Fixes
13+
14+
* **client:** ensure single timer is created per client ([9c57ef5](https://github.com/OneBusAway/java-sdk/commit/9c57ef569421965bce99ce27f8358c5eb20caa52))
15+
16+
17+
### Chores
18+
19+
* **internal:** codegen related update ([ccef12d](https://github.com/OneBusAway/java-sdk/commit/ccef12dd603250750b17aaeded659ea7c0b4b82d))
20+
* **internal:** codegen related update ([96fbb1e](https://github.com/OneBusAway/java-sdk/commit/96fbb1e00da731ee2f86acfa8ec03b9868661bd7))
21+
322
## 0.1.0-alpha.39 (2025-09-13)
423

524
Full Changelog: [v0.1.0-alpha.38...v0.1.0-alpha.39](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.38...v0.1.0-alpha.39)

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/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.39)
6-
[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.39/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.39)
5+
[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.40)
6+
[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.40/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.40)
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.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.39).
18+
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.40).
1919

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

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

2828
```kotlin
29-
implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.39")
29+
implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.40")
3030
```
3131

3232
### Maven
@@ -35,7 +35,7 @@ implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.39")
3535
<dependency>
3636
<groupId>org.onebusaway</groupId>
3737
<artifactId>onebusaway-sdk-java</artifactId>
38-
<version>0.1.0-alpha.39</version>
38+
<version>0.1.0-alpha.40</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 = "org.onebusaway"
11-
version = "0.1.0-alpha.39" // x-release-please-version
11+
version = "0.1.0-alpha.40" // x-release-please-version
1212
}
1313

1414
subprojects {

onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import kotlin.jvm.optionals.getOrNull
1414
import org.onebusaway.client.OnebusawaySdkClient
1515
import org.onebusaway.client.OnebusawaySdkClientImpl
1616
import org.onebusaway.core.ClientOptions
17+
import org.onebusaway.core.Sleeper
1718
import org.onebusaway.core.Timeout
1819
import org.onebusaway.core.http.Headers
1920
import org.onebusaway.core.http.HttpClient
@@ -120,6 +121,17 @@ class OnebusawaySdkOkHttpClient 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
*

onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import kotlin.jvm.optionals.getOrNull
1414
import org.onebusaway.client.OnebusawaySdkClientAsync
1515
import org.onebusaway.client.OnebusawaySdkClientAsyncImpl
1616
import org.onebusaway.core.ClientOptions
17+
import org.onebusaway.core.Sleeper
1718
import org.onebusaway.core.Timeout
1819
import org.onebusaway.core.http.Headers
1920
import org.onebusaway.core.http.HttpClient
@@ -120,6 +121,17 @@ class OnebusawaySdkOkHttpClientAsync 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
*

onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/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 org.onebusaway.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 org.onebusaway.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+
}

onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Properties.kt

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

33
package org.onebusaway.core
44

5-
import java.util.Properties
5+
import org.onebusaway.client.OnebusawaySdkClient
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+
OnebusawaySdkClient::class.java.`package`.implementationVersion ?: "unknown"
4141

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

0 commit comments

Comments
 (0)