Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.3.0"
".": "0.4.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 17
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml
openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f
config_hash: ab495a165f0919b37cbf9efbd0f0e6ef
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml
openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0
config_hash: 4ab3e1ee76a463e0ed214541260ee12e
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 0.4.0 (2026-02-23)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/CASParser/cas-parser-java/compare/v0.3.0...v0.4.0)

### Features

* **api:** api update ([b23e224](https://github.com/CASParser/cas-parser-java/commit/b23e22466dac01c31d286182542dc8146d5fac7d))
* **api:** api update ([cfdb276](https://github.com/CASParser/cas-parser-java/commit/cfdb276b8126bf167b489ded6fc13d84ad876dad))
* **api:** api update ([8d2cb43](https://github.com/CASParser/cas-parser-java/commit/8d2cb43b11b1923624fdc32f7433115f5b20cf37))
* **api:** manual updates ([2bb349e](https://github.com/CASParser/cas-parser-java/commit/2bb349ef8822aeda2d8d47d5f0c27994f9624446))
* **client:** add connection pooling option ([3ad0fbc](https://github.com/CASParser/cas-parser-java/commit/3ad0fbcafa782f6f7dfcead9d4c4646aedd4e681))


### Chores

* **internal:** make `OkHttp` constructor internal ([1939ec1](https://github.com/CASParser/cas-parser-java/commit/1939ec1346feeb7a1ea45db385d6f8b7f8daacf6))
* **internal:** remove mock server code ([0bdc28f](https://github.com/CASParser/cas-parser-java/commit/0bdc28fc1a9ae2e735d2c40d9cf86c1dc00461ae))
* **internal:** update `TestServerExtension` comment ([ff77ead](https://github.com/CASParser/cas-parser-java/commit/ff77ead512a0b13377c61c0e92cc478586e7a67e))
* update mock server docs ([e7286da](https://github.com/CASParser/cas-parser-java/commit/e7286da78e71c2750514686fb39e2b1a0b5140af))

## 0.3.0 (2026-02-14)

Full Changelog: [v0.2.1...v0.3.0](https://github.com/CASParser/cas-parser-java/compare/v0.2.1...v0.3.0)
Expand Down
29 changes: 24 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.cas_parser.api/cas-parser-java)](https://central.sonatype.com/artifact/com.cas_parser.api/cas-parser-java/0.3.0)
[![javadoc](https://javadoc.io/badge2/com.cas_parser.api/cas-parser-java/0.3.0/javadoc.svg)](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.3.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.cas_parser.api/cas-parser-java)](https://central.sonatype.com/artifact/com.cas_parser.api/cas-parser-java/0.4.0)
[![javadoc](https://javadoc.io/badge2/com.cas_parser.api/cas-parser-java/0.4.0/javadoc.svg)](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.4.0)

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

Expand All @@ -22,7 +22,7 @@ Use the Cas Parser MCP Server to enable AI assistants to interact with this API,

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

The REST API documentation can be found on [docs.casparser.in](https://docs.casparser.in). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.3.0).
The REST API documentation can be found on [docs.casparser.in](https://docs.casparser.in). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.4.0).

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

Expand All @@ -33,7 +33,7 @@ The REST API documentation can be found on [docs.casparser.in](https://docs.casp
### Gradle

```kotlin
implementation("com.cas_parser.api:cas-parser-java:0.3.0")
implementation("com.cas_parser.api:cas-parser-java:0.4.0")
```

### Maven
Expand All @@ -42,7 +42,7 @@ implementation("com.cas_parser.api:cas-parser-java:0.3.0")
<dependency>
<groupId>com.cas_parser.api</groupId>
<artifactId>cas-parser-java</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</dependency>
```

Expand Down Expand Up @@ -342,6 +342,25 @@ CasParserClient client = CasParserOkHttpClient.builder()
.build();
```

### Connection pooling

To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:

```java
import com.cas_parser.api.client.CasParserClient;
import com.cas_parser.api.client.okhttp.CasParserOkHttpClient;
import java.time.Duration;

CasParserClient client = CasParserOkHttpClient.builder()
.fromEnv()
// If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.
.maxIdleConnections(10)
.keepAliveDuration(Duration.ofMinutes(2))
.build();
```

If both options are unset, OkHttp's default connection pool settings are used.

### HTTPS

> [!NOTE]
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {

allprojects {
group = "com.cas_parser.api"
version = "0.3.0" // x-release-please-version
version = "0.4.0" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class CasParserOkHttpClient private constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
private var maxIdleConnections: Int? = null
private var keepAliveDuration: Duration? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null
Expand Down Expand Up @@ -75,6 +77,46 @@ class CasParserOkHttpClient private constructor() {
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
fun proxy(proxy: Optional<Proxy>) = proxy(proxy.getOrNull())

/**
* The maximum number of idle connections kept by the underlying OkHttp connection pool.
*
* If this is set, then [keepAliveDuration] must also be set.
*
* If unset, then OkHttp's default is used.
*/
fun maxIdleConnections(maxIdleConnections: Int?) = apply {
this.maxIdleConnections = maxIdleConnections
}

/**
* Alias for [Builder.maxIdleConnections].
*
* This unboxed primitive overload exists for backwards compatibility.
*/
fun maxIdleConnections(maxIdleConnections: Int) =
maxIdleConnections(maxIdleConnections as Int?)

/**
* Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`.
*/
fun maxIdleConnections(maxIdleConnections: Optional<Int>) =
maxIdleConnections(maxIdleConnections.getOrNull())

/**
* The keep-alive duration for idle connections in the underlying OkHttp connection pool.
*
* If this is set, then [maxIdleConnections] must also be set.
*
* If unset, then OkHttp's default is used.
*/
fun keepAliveDuration(keepAliveDuration: Duration?) = apply {
this.keepAliveDuration = keepAliveDuration
}

/** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */
fun keepAliveDuration(keepAliveDuration: Optional<Duration>) =
keepAliveDuration(keepAliveDuration.getOrNull())

/**
* The socket factory used to secure HTTPS connections.
*
Expand Down Expand Up @@ -328,6 +370,8 @@ class CasParserOkHttpClient private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
.maxIdleConnections(maxIdleConnections)
.keepAliveDuration(keepAliveDuration)
.dispatcherExecutorService(dispatcherExecutorService)
.sslSocketFactory(sslSocketFactory)
.trustManager(trustManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class CasParserOkHttpClientAsync private constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
private var maxIdleConnections: Int? = null
private var keepAliveDuration: Duration? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null
Expand Down Expand Up @@ -75,6 +77,46 @@ class CasParserOkHttpClientAsync private constructor() {
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
fun proxy(proxy: Optional<Proxy>) = proxy(proxy.getOrNull())

/**
* The maximum number of idle connections kept by the underlying OkHttp connection pool.
*
* If this is set, then [keepAliveDuration] must also be set.
*
* If unset, then OkHttp's default is used.
*/
fun maxIdleConnections(maxIdleConnections: Int?) = apply {
this.maxIdleConnections = maxIdleConnections
}

/**
* Alias for [Builder.maxIdleConnections].
*
* This unboxed primitive overload exists for backwards compatibility.
*/
fun maxIdleConnections(maxIdleConnections: Int) =
maxIdleConnections(maxIdleConnections as Int?)

/**
* Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`.
*/
fun maxIdleConnections(maxIdleConnections: Optional<Int>) =
maxIdleConnections(maxIdleConnections.getOrNull())

/**
* The keep-alive duration for idle connections in the underlying OkHttp connection pool.
*
* If this is set, then [maxIdleConnections] must also be set.
*
* If unset, then OkHttp's default is used.
*/
fun keepAliveDuration(keepAliveDuration: Duration?) = apply {
this.keepAliveDuration = keepAliveDuration
}

/** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */
fun keepAliveDuration(keepAliveDuration: Optional<Duration>) =
keepAliveDuration(keepAliveDuration.getOrNull())

/**
* The socket factory used to secure HTTPS connections.
*
Expand Down Expand Up @@ -328,6 +370,8 @@ class CasParserOkHttpClientAsync private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
.maxIdleConnections(maxIdleConnections)
.keepAliveDuration(keepAliveDuration)
.dispatcherExecutorService(dispatcherExecutorService)
.sslSocketFactory(sslSocketFactory)
.trustManager(trustManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import java.time.Duration
import java.util.concurrent.CancellationException
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ExecutorService
import java.util.concurrent.TimeUnit
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
import okhttp3.Call
import okhttp3.Callback
import okhttp3.ConnectionPool
import okhttp3.Dispatcher
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
Expand All @@ -33,7 +35,7 @@ import okhttp3.logging.HttpLoggingInterceptor
import okio.BufferedSink

class OkHttpClient
private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient {
internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient {

override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
val call = newCall(request, requestOptions)
Expand Down Expand Up @@ -200,6 +202,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien

private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
private var maxIdleConnections: Int? = null
private var keepAliveDuration: Duration? = null
private var dispatcherExecutorService: ExecutorService? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
Expand All @@ -211,6 +215,28 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien

fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }

/**
* Sets the maximum number of idle connections kept by the underlying [ConnectionPool].
*
* If this is set, then [keepAliveDuration] must also be set.
*
* If unset, then OkHttp's default is used.
*/
fun maxIdleConnections(maxIdleConnections: Int?) = apply {
this.maxIdleConnections = maxIdleConnections
}

/**
* Sets the keep-alive duration for idle connections in the underlying [ConnectionPool].
*
* If this is set, then [maxIdleConnections] must also be set.
*
* If unset, then OkHttp's default is used.
*/
fun keepAliveDuration(keepAliveDuration: Duration?) = apply {
this.keepAliveDuration = keepAliveDuration
}

fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply {
this.dispatcherExecutorService = dispatcherExecutorService
}
Expand Down Expand Up @@ -240,6 +266,22 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien
.apply {
dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) }

val maxIdleConnections = maxIdleConnections
val keepAliveDuration = keepAliveDuration
if (maxIdleConnections != null && keepAliveDuration != null) {
connectionPool(
ConnectionPool(
maxIdleConnections,
keepAliveDuration.toNanos(),
TimeUnit.NANOSECONDS,
)
)
} else {
check((maxIdleConnections != null) == (keepAliveDuration != null)) {
"Both or none of `maxIdleConnections` and `keepAliveDuration` must be set, but only one was set"
}
}

val sslSocketFactory = sslSocketFactory
val trustManager = trustManager
if (sslSocketFactory != null && trustManager != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.cas_parser.api.services.blocking.CamsKfintechService
import com.cas_parser.api.services.blocking.CdslService
import com.cas_parser.api.services.blocking.ContractNoteService
import com.cas_parser.api.services.blocking.CreditService
import com.cas_parser.api.services.blocking.InboundEmailService
import com.cas_parser.api.services.blocking.InboxService
import com.cas_parser.api.services.blocking.KfintechService
import com.cas_parser.api.services.blocking.LogService
Expand Down Expand Up @@ -74,6 +75,8 @@ interface CasParserClient {

fun smart(): SmartService

fun inboundEmail(): InboundEmailService

/**
* Closes this client, relinquishing any underlying resources.
*
Expand Down Expand Up @@ -118,5 +121,7 @@ interface CasParserClient {
fun nsdl(): NsdlService.WithRawResponse

fun smart(): SmartService.WithRawResponse

fun inboundEmail(): InboundEmailService.WithRawResponse
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.cas_parser.api.services.async.CamsKfintechServiceAsync
import com.cas_parser.api.services.async.CdslServiceAsync
import com.cas_parser.api.services.async.ContractNoteServiceAsync
import com.cas_parser.api.services.async.CreditServiceAsync
import com.cas_parser.api.services.async.InboundEmailServiceAsync
import com.cas_parser.api.services.async.InboxServiceAsync
import com.cas_parser.api.services.async.KfintechServiceAsync
import com.cas_parser.api.services.async.LogServiceAsync
Expand Down Expand Up @@ -74,6 +75,8 @@ interface CasParserClientAsync {

fun smart(): SmartServiceAsync

fun inboundEmail(): InboundEmailServiceAsync

/**
* Closes this client, relinquishing any underlying resources.
*
Expand Down Expand Up @@ -122,5 +125,7 @@ interface CasParserClientAsync {
fun nsdl(): NsdlServiceAsync.WithRawResponse

fun smart(): SmartServiceAsync.WithRawResponse

fun inboundEmail(): InboundEmailServiceAsync.WithRawResponse
}
}
Loading
Loading