Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
Expand All @@ -47,10 +47,10 @@ jobs:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
Expand Down Expand Up @@ -85,10 +85,10 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/courier-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-sonatype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: github.repository == 'trycourier/courier-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Check release environment
run: |
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.7.1"
".": "4.8.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 78
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-e3e54d99e2a73fd87519270f2685131050d342e86a4e96130247b854deae5c20.yml
openapi_spec_hash: 897a3fbee24f24d021d6af0df480220c
config_hash: 66a5c28bb74d78454456d9ce7d1c0a0c
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9a543994a29d199daec5228c34a90caf017db9a1084289f58645c6849b606940.yml
openapi_spec_hash: f2f64858daadb0a1978b0e4a4d8ed149
config_hash: ba6cf7f4dbdf6b9d03c6962dd1770569
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 4.8.0 (2026-01-22)

Full Changelog: [v4.7.1...v4.8.0](https://github.com/trycourier/courier-java/compare/v4.7.1...v4.8.0)

### Features

* **client:** send `X-Stainless-Kotlin-Version` header ([11e5765](https://github.com/trycourier/courier-java/commit/11e5765a138fa78d8aaf0abc3df4dffd1493d3b4))


### Bug Fixes

* **client:** disallow coercion from float to int ([5263a13](https://github.com/trycourier/courier-java/commit/5263a1385622f70224b69681b7f75661d89107ef))
* **client:** fully respect max retries ([33cdc16](https://github.com/trycourier/courier-java/commit/33cdc16ed453f885b62c996480751a45035e0afd))
* **client:** send retry count header for max retries 0 ([33cdc16](https://github.com/trycourier/courier-java/commit/33cdc16ed453f885b62c996480751a45035e0afd))
* date time deserialization leniency ([fa50329](https://github.com/trycourier/courier-java/commit/fa50329d5f5e1cd2c555d5deb71b4dd4d8a57c4a))


### Chores

* **ci:** upgrade `actions/setup-java` ([01049af](https://github.com/trycourier/courier-java/commit/01049af97f49ca7d1ad74d09017838263e24735f))
* **internal:** clean up maven repo artifact script and add html documentation to repo root ([e1937ab](https://github.com/trycourier/courier-java/commit/e1937aba76551a3e486cb8961c3f1e0981d9a57f))
* **internal:** depend on packages directly in example ([33cdc16](https://github.com/trycourier/courier-java/commit/33cdc16ed453f885b62c996480751a45035e0afd))
* **internal:** improve maven repo docs ([af0c83b](https://github.com/trycourier/courier-java/commit/af0c83b582d3d26589a0f1176405a365df1e26b5))
* **internal:** update `actions/checkout` version ([337fcd7](https://github.com/trycourier/courier-java/commit/337fcd7a6f5f7d5747ab6f48e74287e58d18eca0))
* **internal:** update maven repo doc to include authentication ([dbf1829](https://github.com/trycourier/courier-java/commit/dbf182983acea01de5784fe9df85f1d43482de5a))
* test on Jackson 2.14.0 to avoid encountering FasterXML/jackson-databind[#3240](https://github.com/trycourier/courier-java/issues/3240) in tests ([fa50329](https://github.com/trycourier/courier-java/commit/fa50329d5f5e1cd2c555d5deb71b4dd4d8a57c4a))

## 4.7.1 (2026-01-14)

Full Changelog: [v4.7.0...v4.7.1](https://github.com/trycourier/courier-java/compare/v4.7.0...v4.7.1)
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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

[![Maven Central](https://img.shields.io/maven-central/v/com.courier/courier-java)](https://central.sonatype.com/artifact/com.courier/courier-java/4.7.1)
[![javadoc](https://javadoc.io/badge2/com.courier/courier-java/4.7.1/javadoc.svg)](https://javadoc.io/doc/com.courier/courier-java/4.7.1)
[![Maven Central](https://img.shields.io/maven-central/v/com.courier/courier-java)](https://central.sonatype.com/artifact/com.courier/courier-java/4.8.0)
[![javadoc](https://javadoc.io/badge2/com.courier/courier-java/4.8.0/javadoc.svg)](https://javadoc.io/doc/com.courier/courier-java/4.8.0)

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

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

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

The REST API documentation can be found on [www.courier.com](https://www.courier.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.courier/courier-java/4.7.1).
The REST API documentation can be found on [www.courier.com](https://www.courier.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.courier/courier-java/4.8.0).

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

Expand All @@ -24,7 +24,7 @@ The REST API documentation can be found on [www.courier.com](https://www.courier
### Gradle

```kotlin
implementation("com.courier:courier-java:4.7.1")
implementation("com.courier:courier-java:4.8.0")
```

### Maven
Expand All @@ -33,7 +33,7 @@ implementation("com.courier:courier-java:4.7.1")
<dependency>
<groupId>com.courier</groupId>
<artifactId>courier-java</artifactId>
<version>4.7.1</version>
<version>4.8.0</version>
</dependency>
```

Expand Down Expand Up @@ -310,6 +310,8 @@ If the SDK threw an exception, but you're _certain_ the version is compatible, t
> [!CAUTION]
> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.

Also note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.

## Network options

### Retries
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {

allprojects {
group = "com.courier"
version = "4.7.1" // x-release-please-version
version = "4.8.0" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien
fun build(): OkHttpClient =
OkHttpClient(
okhttp3.OkHttpClient.Builder()
// `RetryingHttpClient` handles retries if the user enabled them.
.retryOnConnectionFailure(false)
.connectTimeout(timeout.connect())
.readTimeout(timeout.read())
.writeTimeout(timeout.write())
Expand Down
18 changes: 10 additions & 8 deletions courier-java-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ plugins {

configurations.all {
resolutionStrategy {
// Compile and test against a lower Jackson version to ensure we're compatible with it.
// We publish with a higher version (see below) to ensure users depend on a secure version by default.
force("com.fasterxml.jackson.core:jackson-core:2.13.4")
force("com.fasterxml.jackson.core:jackson-databind:2.13.4")
force("com.fasterxml.jackson.core:jackson-annotations:2.13.4")
force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4")
force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4")
force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4")
// Compile and test against a lower Jackson version to ensure we're compatible with it. Note that
// we generally support 2.13.4, but test against 2.14.0 because 2.13.4 has some annoying (but
// niche) bugs (users should upgrade if they encounter them). We publish with a higher version
// (see below) to ensure users depend on a secure version by default.
force("com.fasterxml.jackson.core:jackson-core:2.14.0")
force("com.fasterxml.jackson.core:jackson-databind:2.14.0")
force("com.fasterxml.jackson.core:jackson-annotations:2.14.0")
force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.0")
force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0")
force("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ private constructor(
headers.put("X-Stainless-Package-Version", getPackageVersion())
headers.put("X-Stainless-Runtime", "JRE")
headers.put("X-Stainless-Runtime-Version", getJavaVersion())
headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString())
apiKey.let {
if (!it.isEmpty()) {
headers.put("Authorization", "Bearer $it")
Expand Down
34 changes: 22 additions & 12 deletions courier-java-core/src/main/kotlin/com/courier/core/ObjectMappers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import java.io.InputStream
import java.time.DateTimeException
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.OffsetDateTime
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoField
Expand All @@ -36,7 +37,7 @@ fun jsonMapper(): JsonMapper =
.addModule(
SimpleModule()
.addSerializer(InputStreamSerializer)
.addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer())
.addDeserializer(OffsetDateTime::class.java, LenientOffsetDateTimeDeserializer())
)
.withCoercionConfig(LogicalType.Boolean) {
it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
Expand All @@ -47,6 +48,7 @@ fun jsonMapper(): JsonMapper =
}
.withCoercionConfig(LogicalType.Integer) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
Expand All @@ -64,6 +66,12 @@ fun jsonMapper(): JsonMapper =
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.DateTime) {
it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.Array) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
Expand Down Expand Up @@ -124,10 +132,10 @@ private object InputStreamSerializer : BaseSerializer<InputStream>(InputStream::
}

/**
* A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes.
* A deserializer that can deserialize [OffsetDateTime] from datetimes, dates, and zoned datetimes.
*/
private class LenientLocalDateTimeDeserializer :
StdDeserializer<LocalDateTime>(LocalDateTime::class.java) {
private class LenientOffsetDateTimeDeserializer :
StdDeserializer<OffsetDateTime>(OffsetDateTime::class.java) {

companion object {

Expand All @@ -141,26 +149,28 @@ private class LenientLocalDateTimeDeserializer :

override fun logicalType(): LogicalType = LogicalType.DateTime

override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime {
override fun deserialize(p: JsonParser, context: DeserializationContext): OffsetDateTime {
val exceptions = mutableListOf<Exception>()

for (formatter in DATE_TIME_FORMATTERS) {
try {
val temporal = formatter.parse(p.text)

return when {
!temporal.isSupported(ChronoField.HOUR_OF_DAY) ->
LocalDate.from(temporal).atStartOfDay()
!temporal.isSupported(ChronoField.OFFSET_SECONDS) ->
LocalDateTime.from(temporal)
else -> ZonedDateTime.from(temporal).toLocalDateTime()
}
!temporal.isSupported(ChronoField.HOUR_OF_DAY) ->
LocalDate.from(temporal).atStartOfDay()
!temporal.isSupported(ChronoField.OFFSET_SECONDS) ->
LocalDateTime.from(temporal)
else -> ZonedDateTime.from(temporal).toLocalDateTime()
}
.atZone(context.timeZone.toZoneId())
.toOffsetDateTime()
} catch (e: DateTimeException) {
exceptions.add(e)
}
}

throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply {
throw JsonParseException(p, "Cannot parse `OffsetDateTime` from value: ${p.text}").apply {
exceptions.forEach { addSuppressed(it) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ private constructor(
) : HttpClient {

override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
if (!isRetryable(request) || maxRetries <= 0) {
return httpClient.execute(request, requestOptions)
}

var modifiedRequest = maybeAddIdempotencyHeader(request)

// Don't send the current retry count in the headers if the caller set their own value.
Expand All @@ -48,6 +44,10 @@ private constructor(
modifiedRequest = setRetryCountHeader(modifiedRequest, retries)
}

if (!isRetryable(modifiedRequest)) {
return httpClient.execute(modifiedRequest, requestOptions)
}

val response =
try {
val response = httpClient.execute(modifiedRequest, requestOptions)
Expand Down Expand Up @@ -75,10 +75,6 @@ private constructor(
request: HttpRequest,
requestOptions: RequestOptions,
): CompletableFuture<HttpResponse> {
if (!isRetryable(request) || maxRetries <= 0) {
return httpClient.executeAsync(request, requestOptions)
}

val modifiedRequest = maybeAddIdempotencyHeader(request)

// Don't send the current retry count in the headers if the caller set their own value.
Expand All @@ -94,8 +90,12 @@ private constructor(
val requestWithRetryCount =
if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request

return httpClient
.executeAsync(requestWithRetryCount, requestOptions)
val responseFuture = httpClient.executeAsync(requestWithRetryCount, requestOptions)
if (!isRetryable(requestWithRetryCount)) {
return responseFuture
}

return responseFuture
.handleAsync(
fun(
response: HttpResponse?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private constructor(
.toList()
return when (bestMatches.size) {
// This can happen if what we're deserializing is completely incompatible with all
// the possible variants (e.g. deserializing from array).
// the possible variants (e.g. deserializing from boolean).
0 -> MessageRoutingChannel(_json = json)
1 -> bestMatches.single()
// If there's more than one match with the highest validity, then use the first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private constructor(
.toList()
return when (bestMatches.size) {
// This can happen if what we're deserializing is completely incompatible with all
// the possible variants (e.g. deserializing from object).
// the possible variants (e.g. deserializing from boolean).
0 -> UserProfileFirebaseToken(_json = json)
1 -> bestMatches.single()
// If there's more than one match with the highest validity, then use the first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ private constructor(
.toList()
return when (bestMatches.size) {
// This can happen if what we're deserializing is completely incompatible
// with all the possible variants (e.g. deserializing from array).
// with all the possible variants (e.g. deserializing from boolean).
0 -> Content(_json = json)
1 -> bestMatches.single()
// If there's more than one match with the highest validity, then use the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,7 @@ private constructor(
return when (bestMatches.size) {
// This can happen if what we're deserializing is completely
// incompatible with all the possible variants (e.g. deserializing from
// object).
// boolean).
0 -> ExpiresIn(_json = json)
1 -> bestMatches.single()
// If there's more than one match with the highest validity, then use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ private constructor(
.toList()
return when (bestMatches.size) {
// This can happen if what we're deserializing is completely incompatible with
// all the possible variants (e.g. deserializing from object).
// all the possible variants (e.g. deserializing from integer).
0 -> ExpiryDate(_json = json)
1 -> bestMatches.single()
// If there's more than one match with the highest validity, then use the first
Expand Down
Loading
Loading