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

Variables (ENV=...) in @DatasourceDefinition not applied to 'className' / FISH-1014 #5095

Closed
thehpi opened this issue Jan 14, 2021 · 8 comments
Assignees
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Bug Label issue as a bug defect

Comments

@thehpi
Copy link

thehpi commented Jan 14, 2021

Description

In a @DatasourceDefinition the 'className' property cannot be configured using "${ENV:ENVIRONMENT_VARIABLE_NAME}"

If I use this in the web.xml however (currently web.xml.old) then it does work!

Reproduce

See this github repo for the issue description and to reproduce it.

@AlanRoth AlanRoth self-assigned this Jan 15, 2021
@AlanRoth AlanRoth 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 Jan 15, 2021
@AlanRoth
Copy link

Hi @thehpi,

Following your reproducer steps, the build fails with PSQLException: The connection attempt failed.. Any advice on what I may be doing wrong?

Thank you,
Alan

@AlanRoth AlanRoth added Status: Pending Waiting on the issue requester to give more details or share a reproducer and removed Status: Open Issue has been triaged by the front-line engineers and is being worked on verification labels Jan 15, 2021
@thehpi
Copy link
Author

thehpi commented Jan 16, 2021 via email

@thehpi
Copy link
Author

thehpi commented Jan 16, 2021

Ow I now see what you mean, the build is failing because of a test which assumes the db is running.

I removed the test, now it builds so you can reproduce. Apologies.

@AlanRoth AlanRoth added Status: Open Issue has been triaged by the front-line engineers and is being worked on verification and removed Status: Pending Waiting on the issue requester to give more details or share a reproducer labels Jan 18, 2021
@AlanRoth
Copy link

Hi @thehpi,

I have been able to reproduce the issue with the change, I created an internal ticket FISH-1014 to keep track of this. Are you able to submit a PR to fix this? Due to the influx of community contributions our dev team may take a while to get around to fixing this.

Thank you,
Alan

@AlanRoth AlanRoth changed the title Variables (ENV=...) in @DatasourceDefinition not applied to 'className' Variables (ENV=...) in @DatasourceDefinition not applied to 'className' \ FISH-1014 Jan 18, 2021
@AlanRoth AlanRoth added Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev and removed Status: Open Issue has been triaged by the front-line engineers and is being worked on verification labels Jan 18, 2021
@AlanRoth
Copy link

Hi @thehpi,

It seems like #5024 may be related to your issue, could you confirm that this is also related to your issue? I do not want to prematurely close this issue without your input if you determine they are different issues.

Thank you,
Alan

@thehpi
Copy link
Author

thehpi commented Jan 20, 2021 via email

@poikilotherm
Copy link
Contributor

Suspecting that

if (adminPool.getResType() != null) {
if (ConnectorConstants.JAVA_SQL_DRIVER.equals(adminPool.getResType())) {
propList.add(new ConnectorConfigProperty("ClassName",
adminPool.getDriverClassname() == null ? "" : adminPool.getDriverClassname(),
"The driver class name", "java.lang.String"));
} else {
propList.add(new ConnectorConfigProperty("ClassName",
adminPool.getDatasourceClassname() == null ? "" : adminPool.getDatasourceClassname(),
"The datasource class name", "java.lang.String"));
}
} else {
//When resType is null, one of these classnames would be specified
if (adminPool.getDriverClassname() != null) {
propList.add(new ConnectorConfigProperty("ClassName",
adminPool.getDriverClassname() == null ? "" : adminPool.getDriverClassname(),
"The driver class name", "java.lang.String"));
} else if (adminPool.getDatasourceClassname() != null) {
propList.add(new ConnectorConfigProperty("ClassName",
adminPool.getDatasourceClassname() == null ? "" : adminPool.getDatasourceClassname(),
"The datasource class name", "java.lang.String"));
}
}

does the class name magic, it looks like you cannot use variable substitution for the very same reasons as outlined in #5024.

@thehpi
Copy link
Author

thehpi commented Feb 26, 2021

@poikilotherm, I read #5024 and used TranslatedConfigView to expand the className.

if (adminPool.getResType() != null) {
    if (ConnectorConstants.JAVA_SQL_DRIVER.equals(adminPool.getResType())) {
        propList.add(new ConnectorConfigProperty("ClassName",
                adminPool.getDriverClassname() == null ? "" : TranslatedConfigView.expandValue(adminPool.getDriverClassname()),
                "The driver class name", "java.lang.String"));
    } else {
        propList.add(new ConnectorConfigProperty("ClassName",
                adminPool.getDatasourceClassname() == null ? "" : TranslatedConfigView.expandValue(adminPool.getDatasourceClassname()),
                "The datasource class name", "java.lang.String"));
    }
} else {
    //When resType is null, one of these classnames would be specified
    if (adminPool.getDriverClassname() != null) {
        propList.add(new ConnectorConfigProperty("ClassName",
                adminPool.getDriverClassname() == null ? "" : TranslatedConfigView.expandValue(adminPool.getDriverClassname()),
                "The driver class name", "java.lang.String"));
    } else if (adminPool.getDatasourceClassname() != null) {
        propList.add(new ConnectorConfigProperty("ClassName",
                adminPool.getDatasourceClassname() == null ? "" : TranslatedConfigView.expandValue(adminPool.getDatasourceClassname()),
                "The datasource class name", "java.lang.String"));
    }
}

But I'm getting a setUrl access error.

I think the problem is that adminPool.getDatasourceClassname() is used in many places where the expansion is not performed and doing it at this point causes inconsistencies.

So it will probably better to do the expansion in DataSourceDefinitionHandler.

@fturizo fturizo changed the title Variables (ENV=...) in @DatasourceDefinition not applied to 'className' \ FISH-1014 Variables (ENV=...) in @DatasourceDefinition not applied to 'className' / FISH-1014 Mar 1, 2021
AlanRoth pushed a commit that referenced this issue Mar 11, 2021
FISH-1014 Variables (ENV=...) in @DatasourceDefinition not applied to 'className' #5095
Pandrex247 pushed a commit to Pandrex247/Payara that referenced this issue May 4, 2021
FISH-1014 Variables (ENV=...) in @DatasourceDefinition not applied to 'className' payara#5095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Bug Label issue as a bug defect
Projects
None yet
Development

No branches or pull requests

3 participants