ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Getting `NumberFormatException` when specifying `maxAge` as decimal #6765

Closed TharmiganK closed 3 months ago

TharmiganK commented 3 months ago

Description:

When the maxAge is set to a decimal value, the resource invocation fails with NumberFormatException.

Steps to reproduce:

This can be reproduced with the following sample:

import ballerina/http;

type Album readonly & record {|
    string title;
    string artist;
|};

table<Album> key(title) albums = table [
    {title: "Blue Train", artist: "John Coltrane"},
    {title: "Jeru", artist: "Gerry Mulligan"}
];

service / on new http:Listener(9090) {

    resource function get albums/[string title]() returns @http:Cache {maxAge: 23.45} Album|http:NotFound {
        return albums[title] ?: http:NOT_FOUND;
    }
}

Make a request to the resource with cURL:

$ curl -v http://localhost:9090/albums/Jeru

Affected Versions:

Ballerina SwanLake Update 8 and higher

TharmiganK commented 3 months ago

This error is coming from this parser block: https://github.com/ballerina-platform/module-ballerina-http/blob/883eb410c1536141f36e67b4f0c4d0cca90cd6ef/native/src/main/java/io/ballerina/stdlib/http/api/client/caching/ResponseCacheControlObj.java#L206 where the value is "23.45"

github-actions[bot] commented 3 months ago

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.