Skip to content

Fix kotlinx-datetime RFC_1123 format IllegalStateException - #1

Closed
ShreckYe with Copilot wants to merge 3 commits into
vertx-web-kotlinx-update-dec-2025-use-kotlinx-datetimefrom
copilot/fix-exception-issue
Closed

ShreckYe with Copilot wants to merge 3 commits into
vertx-web-kotlinx-update-dec-2025-use-kotlinx-datetimefrom
copilot/fix-exception-issue

Conversation

Copilot AI commented Dec 7, 2025 •

Copy link
Copy Markdown

The setCurrentDate() method threw IllegalStateException: Field offsetHours is not set when formatting dates with kotlinx-datetime's RFC_1123 format. The setDateTime() method only sets date/time components; RFC_1123 requires timezone offset.

Changes

  • Use setDateTimeOffset() instead of setDateTime() to provide required timezone offset
  • Add UtcOffset import for timezone offset specification
  • Use TimeZone.UTC with UtcOffset.ZERO for consistent UTC timestamps in HTTP Date headers
  • Remove unused timeZone companion object
// Before
fun setCurrentDate() {
    date = DateTimeComponents.Formats.RFC_1123.format {
        setDateTime(Clock.System.now().toLocalDateTime(timeZone))
    }
}

// After
fun setCurrentDate() {
    val now = Clock.System.now()
    date = DateTimeComponents.Formats.RFC_1123.format {
        setDateTimeOffset(now.toLocalDateTime(TimeZone.UTC), UtcOffset.ZERO)
    }
}
Original prompt

See the latest commit message and try fixing the exception.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 7, 2025
Copilot AI changed the title [WIP] Fix exception in latest commit Fix kotlinx-datetime RFC_1123 format IllegalStateException Dec 7, 2025
Copilot AI requested a review from ShreckYe December 7, 2025 18:47
ShreckYe added a commit that referenced this pull request Dec 8, 2025
@ShreckYe

ShreckYe commented Dec 8, 2025

Copy link
Copy Markdown
Member

Replaced by commit b21a11a.

@ShreckYe ShreckYe closed this Dec 8, 2025
msmith-techempower pushed a commit to TechEmpower/FrameworkBenchmarks that referenced this pull request Dec 10, 2025
* Bump all dependencies and toolchains to the latest

* Migrate to Vert.x 5 APIs and bump Kotlin to 2.3.0-RC2 to support Java 25

* Update catching the "connection" reset exceptions

* Try setting `date` with kotlinx-datetime but it doesn't work as expected

Got `java.lang.IllegalStateException: Field offsetHours is not set`.

* Remove the kotlinx-datetime dependency and update the comment

See commit 9cf28f1 for a failed attempt to try using kotlinx-datetime.

* Get setting `date` with `kotlinx-datetime` to work

ref: huanshankeji#1

* Review and port some of the changes in `FrameworkBenchmarks/frameworks/Java/vertx/` from commit 057c25b to commit 1838aa5, and fix some typos

Some changes are not ported.

There is about 5% performance improvement in the JSON test as tested on my device.

* Increase the io_uring completion queue size to resolve warnings and improve the plaintext test performance

```
io.netty.channel.uring.IoUringIoHandler processCompletionsAndHandleOverflow
vertx: WARNING: CompletionQueue overflow detected, consider increasing size: 4096
```

This is still one warning when the value is set to 8192 as tested on my device, instead of many for the default 4096.

* Benchmark Approach 1 and Approach 3 in `jsonResponseCoHandler` again and fix capitalization BTW

The "Requests/sec" result of Approach 1 is only 40% of Approach 3 as tested on my device.

* Remove an outdated comment as found by Gemini Code Assist

* Use the "connection reset" error code from Netty instead of hard-coding it and also catch Java NIO `SocketException` for developing on other OSs such as macOS and Windows

Tested with the `tfb` command on both macOS and Linux.

* Fix some errors and keep things updated in benchmark_config.json and README.md
msmith-techempower pushed a commit to TechEmpower/FrameworkBenchmarks that referenced this pull request Jan 14, 2026
…nt modules and adding new benchmark portions for the Expesed Vert.x SQL Client along with R2DBC and Exposed R2DBC as comparisons (#10560)

* Bump all dependencies and toolchains to the latest

* Migrate to Vert.x 5 APIs and bump Kotlin to 2.3.0-RC2 to support Java 25

* Update catching the "connection" reset exceptions

* Try setting `date` with kotlinx-datetime but it doesn't work as expected

Got `java.lang.IllegalStateException: Field offsetHours is not set`.

* Remove the kotlinx-datetime dependency and update the comment

See commit 9cf28f1 for a failed attempt to try using kotlinx-datetime.

* Get setting `date` with `kotlinx-datetime` to work

ref: huanshankeji#1

* Review and port some of the changes in `FrameworkBenchmarks/frameworks/Java/vertx/` from commit 057c25b to commit 1838aa5, and fix some typos

Some changes are not ported.

There is about 5% performance improvement in the JSON test as tested on my device.

* Increase the io_uring completion queue size to resolve warnings and improve the plaintext test performance

```
io.netty.channel.uring.IoUringIoHandler processCompletionsAndHandleOverflow
vertx: WARNING: CompletionQueue overflow detected, consider increasing size: 4096
```

This is still one warning when the value is set to 8192 as tested on my device, instead of many for the default 4096.

* Benchmark Approach 1 and Approach 3 in `jsonResponseCoHandler` again and fix capitalization BTW

The "Requests/sec" result of Approach 1 is only 40% of Approach 3 as tested on my device.

* Remove an outdated comment as found by Gemini Code Assist

* Use the "connection reset" error code from Netty instead of hard-coding it and also catch Java NIO `SocketException` for developing on other OSs such as macOS and Windows

Tested with the `tfb` command on both macOS and Linux.

* Run `./tfb --new` and update manually

* Copy files from `frameworks/Kotlin/vertx-web-kotlinx`, merge, and update

* Fix some errors and keep things updated in benchmark_config.json and README.md

* Add the exposed-vertx-sql-client dependencies

* Initially adapt the benchmark with some code copied from `frameworks/Kotlin/ktor/ktor-exposed`

The following exception occurs when running the benchmark:

```
org.postgresql.util.PSQLException: Transaction isolation level 0 not supported.
```

* Fix `org.postgresql.util.PSQLException: Transaction isolation level 0 not supported.` with huanshankeji/exposed-vertx-sql-client@bb69856 published to Maven local, and fix some remaining issues in the benchmark code debugging with `tfb`

Here are some results with max parameters (threads, connections, number of queries) of interest as benchmarked on my device. The "single query" result is only 65% of that of `vertx-web-kotlinx`, which is not ideal. The "updates" result exceeds that of `vertx-web-kotlinx` by about 10%-15%, which needs to be looked into further. Setting `validateBatch = false` does not make noticeable difference.

* Use lower case table names

PostgreSQL table names are case-insensitive.

* Port commit e487900 of `vertx-web-kotlinx` here, using one Kotlin `XorWowRandom` `Random` instance every `Verticle

* Rename the project directory to `vertx-web-kotlinx-exposed-vertx-sql-client` to more explicitly compare with the `vertx-web-kotlinx` portion

* Update the project configuration files correspondingly

* Remove the `hasDb` command-line argument

Tests without the database are not needed here in this portion.

* Update the benchmark name in code

* Copy the optimized kotlinx-serialization `Json` configuration from the `ktor` portion

* Merge the `vertx-web-kotlinx-exposed-vertx-sql-client` portion project into the `vertx-web-kotlinx` portion and update the project structure

Changes:
* Split the project into multiple modules/subprojects.
* Update the project structure following a new project generated with `gradle init`.
* Partially adapt to Gradle version catalog (putting only the versions).
* Bump Kotlin to 2.3.0 which is just released BTW.

Common code is not extracted yet.

* Put the serialization plugin in the version catalog too

* Extract common code and refactor for better abstraction

Bump the Vert.x version to 5.0.6 BTW.

* Inline `initDbResources`

* Rename project ":with-db:common" to ":with-db:with-db-common" to resolve jar name conflicts

* Fix Gradle errors of projects without directories

```
Configuring project '...' without an existing directory is not allowed. The configured projectDirectory '...' does not exist, can't be written to or is not a directory.
```

Add an `r2dbc` module BTW.

* Set the main class for the `vertx-web-kotlinx` portion which was forgotten

* Apply Kotlin JVM 2.3.0 explicitly in `buildSrc` to resolve the `Kotlin does not yet support 25 JDK target, falling back to Kotlin JVM_24 JVM target` warning

* Initially complete the `r2dbc` and `exposed-r2dbc` portions

Add a comment for commit effc46a BTW. Update README.md BTW.

* Set username and password which was forgotten and extract the common constants

* Call `suspendTransaction` in the `exposed-r2dbc` portion

* Disable `strictThreadMode` to resolve `java.lang.IllegalStateException: Only the context thread can write a message in the R2DBC portions

* Put all the dependencies in `libraries` of the Gradle version catalog

First performed by Copilot and updated by me to fix some minor issues, reorder, and adjust the format.

* Move the R2DBC `connectionFactory` to the `r2dbc-common` module and share it for the `exposed` module as well, and set `reactor.bufferSize.small` to try resolving `io.r2dbc.postgresql.client.ReactorNettyClient$RequestQueueException: [08006] Cannot exchange messages because the request queue limit is exceeded`

* Set the explicit dialect which is necessary

* Fix `java.lang.IllegalStateException: Bound parameter count does not match parameters in SQL statement` in the `r2dbc` `updates` test with Copilot

* Fix a bug where `awaitLast` should be called instead of `awaitSingle`

* Fix `io.r2dbc.postgresql.client.ReactorNettyClient$RequestQueueException: [08006] Cannot exchange messages because the request queue limit is exceeded` alternatively by not using pipelining

* Update the comments

* Remove the TODO as it's tried in commit 4602312f7c9e6575a5c3dfb75cb78e226aa4c9a1

* Move a comment's location

* Fix the `update` test timeout issue

* Close the R2DBC connection

This doesn't fix the `r2dbc` `update` failure though.

* Fix some warnings

* Use an R2DBC connection pool each `Verticle` in `exposed-r2dbc`, and run the test several times to determine the optimal pool size

* Share one transaction for all the queries in a request in `exposed-r2dbc`, refactoring `CommonWithDbVerticle` to support optional transactions

* Fix format

* Benchmark the `vertx-web-kotlinx` `json` test and `vertx-web-kotlinx-postgresql` `db` test several times with different (original and reverted) code before and after abstraction (introducing abstract classes and interfaces), Kotlin and Vert.x versions, and kotlinx-serialization `Json` configurations to investigate possible performance regressions

Results show no noticeable performance regressions. I first noticed some in the `db` test but they appear to be just measurement errors. The optimized `Json` improves the `json` test throughput with max parameters by about 5% as tested on my device but there is no noticeable difference in the `db` test.

* Use the newly released version 0.7.0 of `exposed-vertx-sql-client`

* Temporarily remove 'update_url' from benchmark_config.json whose corresponding test fails

See #10432 which is not fixed yet.

* Revert "Temporarily remove 'update_url' from benchmark_config.json whose corresponding test fails"

This reverts commit 3f1e03e.

The wrong `update_url` was removed.

* Fix vertx-web-kotlinx-r2dbc-postgresql update test by consuming batch Result publishers (#7)

* Initial plan

* Fix updateSortedWorlds to properly consume R2DBC batch update results

Co-authored-by: ShreckYe <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: ShreckYe <[email protected]>

* Update endpoint URLs to match the code as suggested by Copilot

* Comment out `mavenLocal()`

* Update an outdated relative path as suggested by Copilot

* Fix the `orm` field of `r2dbc-postgresql` which was copied here

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: ShreckYe <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants