Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: CacheFactory does not create a LRUCacheImpl from @DataSourceDefinition propertiy fish.payara.statement-cache-type #6647

Open
franzmathauser opened this issue Apr 23, 2024 · 1 comment
Assignees
Labels
Status: Open Issue has been triaged by the front-line engineers and is being worked on verification Type: Bug Label issue as a bug defect

Comments

@franzmathauser
Copy link

franzmathauser commented Apr 23, 2024

Brief Summary

CacheFactory runs into an error, because null value is interpreted as "null"-string value.

Resulting error log: Error while creating the Statement cache data structure for type : null

This happens if no @DataSourceDefinition > propertiy > fish.payara.statement-cache-type is set and a cache-size > 0.

A workaround for this is to set a whitespace string for the property, which seems not intuitive.

@DataSourceDefinition(name = "java:app/jdbc/store",
    className = "${query.store.driver}",
    isolationLevel = Connection.TRANSACTION_READ_COMMITTED,
    url = "${url}",
    transactional = false,
    user = "${user}",
    password = "${password}",
    initialPoolSize = 10, // otherwise defaults to -1
    minPoolSize = 10, // otherwise defaults to -1
    maxPoolSize = 32, // otherwise defaults to -1
    properties = {"ReadOnly=false",
        "fish.payara.connection-creation-retry-attempts=10",
        "fish.payara.connection-creation-retry-interval-in-seconds=10",
        "fish.payara.pooling=false",
        "fish.payara.statement-cache-size=20",
        "fish.payara.statement-cache-type= " 
}

Expected Outcome

If cache size is set > 0 a LRUCacheImpl must be returned by the CacheFactory if nothing else is set.

Current Outcome

Error while creating the Statement cache data structure for type : null

Reproducer

Please be aware of the "null" and null here, since this might be confusing.

Given this DataSourceDefinition

@DataSourceDefinition(name = "java:app/jdbc/store",
    className = "${query.store.driver}",
    isolationLevel = Connection.TRANSACTION_READ_COMMITTED,
    url = "${url}",
    transactional = false,
    user = "${user}",
    password = "${password}",
    initialPoolSize = 10, // otherwise defaults to -1
    minPoolSize = 10, // otherwise defaults to -1
    maxPoolSize = 32, // otherwise defaults to -1
    properties = {"ReadOnly=false",
        "fish.payara.connection-creation-retry-attempts=10",
        "fish.payara.connection-creation-retry-interval-in-seconds=10",
        "fish.payara.pooling=false",
        "fish.payara.statement-cache-size=20",
}

the following section will append an empty string to the null value. which results in a "null" string value

https://github.com/payara/Payara/blob/master/appserver/jdbc/jdbc-runtime/src/main/java/org/glassfish/jdbc/deployer/JdbcConnectionPoolDeployer.java#L410

In the CacheFactory the "null" string will end up in the initCustomCacheStructurePrivileged path, which creates a ClassNotFoundException.

https://github.com/payara/Payara/blob/master/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/datastructure/CacheFactory.java#L71

if i substitute the cacheType with the receiving value it would look like this

if("null" == null || "null".trim().equals("")) { ...

Operating System

any

JDK Version

openjdk version "17.0.3" 2022-04-19 LTS

Payara Distribution

Payara Micro

@franzmathauser franzmathauser added Status: Open Issue has been triaged by the front-line engineers and is being worked on verification Type: Bug Label issue as a bug defect labels Apr 23, 2024
@franzmathauser franzmathauser changed the title Bug Report: CacheFactory @DataSourceDefinition propertiy fish.payara.statement-cache-type Bug Report: CacheFactory does not create a LRUCacheImpl from @DataSourceDefinition propertiy fish.payara.statement-cache-type Apr 23, 2024
@franzmathauser
Copy link
Author

franzmathauser commented May 3, 2024

any update or initial thoughts on this topic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Open Issue has been triaged by the front-line engineers and is being worked on verification Type: Bug Label issue as a bug defect
Projects
None yet
Development

No branches or pull requests

2 participants