You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "pingpingy1 (via GitHub)" <gi...@apache.org> on 2024/02/25 13:23:33 UTC
[PR] Return empty internal keys for DatabaseConfiguration if no Datasource [commons-configuration]
pingpingy1 opened a new pull request, #368:
URL: https://github.com/apache/commons-configuration/pull/368
The current implementation of `DatabaseConfiguration.getKeysInternal` throws an NPE (with a rather convoluted error trace, might I add) if the `Datasource` of the instance has not been set.
It might be a better description to return an empty iterator in those cases, which this PR intends to implement.
Example:
```java
import org.apache.commons.configuration2.ConfigurationUtils;
import org.apache.commons.configuration2.DatabaseConfiguration;
public class Test {
public static void main(String args[]) throws Exception {
ConfigurationUtils.toString(new DatabaseConfiguration());
}
}
```
```console
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "javax.sql.DataSource.getConnection()" because the return value of "org.apache.commons.configuration2.DatabaseConfiguration.getDatasource()" is null
at org.apache.commons.configuration2.DatabaseConfiguration$AbstractJdbcOperation.execute(DatabaseConfiguration.java:615)
at org.apache.commons.configuration2.DatabaseConfiguration.getKeysInternal(DatabaseConfiguration.java:481)
at org.apache.commons.configuration2.AbstractConfiguration.getKeys(AbstractConfiguration.java:752)
at org.apache.commons.configuration2.ConfigurationUtils.dump(ConfigurationUtils.java:114)
at org.apache.commons.configuration2.ConfigurationUtils.toString(ConfigurationUtils.java:149)
at org.apache.commons.configuration2.ConfigurationUtils.toString(ConfigurationUtils.java:161)
at Test.main(Test.java:6)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Return empty internal keys for DatabaseConfiguration if no Datasource [commons-configuration]
Posted by "pingpingy1 (via GitHub)" <gi...@apache.org>.
pingpingy1 commented on PR #368:
URL: https://github.com/apache/commons-configuration/pull/368#issuecomment-1975659822
@garydgregory Thanks for the update!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Return empty internal keys for DatabaseConfiguration if no Datasource [commons-configuration]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #368:
URL: https://github.com/apache/commons-configuration/pull/368#issuecomment-1975194766
Hello @pingpingy1
Thank you for your PR.
I fixed this issue slightly differently, now in git master and snapshot builds.
You are credited in `chnages.xml`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Return empty internal keys for DatabaseConfiguration if no Datasource [commons-configuration]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory closed pull request #368: Return empty internal keys for DatabaseConfiguration if no Datasource
URL: https://github.com/apache/commons-configuration/pull/368
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Return empty internal keys for DatabaseConfiguration if no Datasource [commons-configuration]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #368:
URL: https://github.com/apache/commons-configuration/pull/368#issuecomment-1974930568
## [Codecov](https://app.codecov.io/gh/apache/commons-configuration/pull/368?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 89.08%. Comparing base [(`ad9eaa0`)](https://app.codecov.io/gh/apache/commons-configuration/commit/ad9eaa0199524c603bee36483f93b2b2431295e6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`d18241a`)](https://app.codecov.io/gh/apache/commons-configuration/pull/368?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 32 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #368 +/- ##
============================================
- Coverage 89.09% 89.08% -0.01%
- Complexity 3536 3537 +1
============================================
Files 183 183
Lines 9635 9637 +2
Branches 1192 1193 +1
============================================
+ Hits 8584 8585 +1
Misses 772 772
- Partials 279 280 +1
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/commons-configuration/pull/368?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org