Skip to content

class java.lang.String cannot be cast to class java.time.Duration #412

Closed

Description

@lmm1990

connectionUrl:r2dbc:mysql://localhost:3036/production?connectTimeout=PT3S

Exception at jasync-r2dbc-mysql-2.2.0-sources.jar!\MysqlConnectionFactoryProvider.kt#create

connectionTimeout = (connectionFactoryOptions.getValue(CONNECT_TIMEOUT) as Duration?)?.toMillis()?.toInt() ?: 5000,

r2dbc-spi-1.0.0.RELEASE-sources.jar!\io\r2dbc\spi\ConnectionUrlParser.java#parseQuery

if (hasText(uri.getRawQuery())) {
            parseQuery(uri.getRawQuery().trim(), (k, v) -> {

                if (PROHIBITED_QUERY_OPTIONS.contains(k)) {
                    throw new IllegalArgumentException(
                        String.format("URL %s must not declare option %s in the query string", url, k));
                }

                builder.option(Option.valueOf(k), v);
            });
        }

option value is object(true type string)

see:r2dbc/r2dbc-spi#205

suggestion

jasync-r2dbc-mysql-2.2.0-sources.jar!\MysqlConnectionFactoryProvider.kt#create

var connectionTimeoutMs = 5000
if(connectionFactoryOptions.getValue(CONNECT_TIMEOUT)!=null){
    connectionTimeoutMs = Duration.parse(connectionFactoryOptions.getValue(CONNECT_TIMEOUT) as String)?.toMillis()?.toInt()
}
connectionTimeout = connectionTimeoutMs

Activity

  1. github-actions commented on Aug 24, 2023

    @github-actions

    Thank you for reporting an issue. See the wiki for documentation and gitter for questions.

  2. oshai commented on Sep 3, 2023

    @oshai
    Contributor

    Thanks for reporting the issue, I am adding a fix.

  3. oshai commented on Sep 4, 2023

    @oshai
    Contributor

    Fixed in 2.2.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions