Skip to content

Config.toml allows integer for decimal but runtime throws ClassCastException #1265

@Nuvindu

Description

@Nuvindu

Description

When using WSO2 Integrator, Config.toml allows assigning an integer(5) value to a configurable variable defined as decimal. However, at runtime this results in a ClassCastException indicating a mismatch. If the value is set as a decimal value (5.0), it works as expected.

Exception in thread "main" java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Double (java.lang.Long and java.lang.Double are in module java.base of loader 'bootstrap')
        at io.ballerina.runtime.internal.configurable.providers.toml.TomlProvider.getAsDecimalAndMark(TomlProvider.java:221)
        at io.ballerina.runtime.internal.configurable.ConfigResolver.lambda$getValueFunction$5(ConfigResolver.java:114)
        at io.ballerina.runtime.internal.configurable.ConfigResolver.getConfigValue(ConfigResolver.java:156)
        at io.ballerina.runtime.internal.configurable.ConfigResolver.getConfigValue(ConfigResolver.java:96)
        at io.ballerina.runtime.internal.configurable.ConfigResolver.resolveConfigs(ConfigResolver.java:83)
        at io.ballerina.runtime.internal.launch.LaunchUtils.initConfigurableVariables(LaunchUtils.java:124)
        at nuvindu.file_int_with_copilot.0.$_init.main(file_int_with_copilot)

Steps to Reproduce

  1. Create an integration using WSO2 Integrator.
  2. Define a configurable variable of type decimal.
  3. In Config.toml, assign an integer value. (myDecimalVar = 5)
  4. Run the integration.

Version

5.0.0-alpha13

Environment Details (with versions)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions