You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2014/08/08 10:57:11 UTC
[jira] [Resolved] (DERBY-6695) Improving configuration code: should
not silently replace an invalid value with the default one
[ https://issues.apache.org/jira/browse/DERBY-6695?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Knut Anders Hatlen resolved DERBY-6695.
---------------------------------------
Resolution: Duplicate
Hi Sai,
This sounds like a good suggestion.
The problem has been reported before (DERBY-2844), so I'm marking this report as a duplicate. Feel free to add your vote to that issue to give it higher visibility. Patches are also welcome. :)
> Improving configuration code: should not silently replace an invalid value with the default one
> -----------------------------------------------------------------------------------------------
>
> Key: DERBY-6695
> URL: https://issues.apache.org/jira/browse/DERBY-6695
> Project: Derby
> Issue Type: Bug
> Affects Versions: 10.10.1.1
> Environment: All envrionments
> Reporter: Sai Zhang
> Labels: configuration, easyfix
> Original Estimate: 5m
> Remaining Estimate: 5m
>
> Dear Derby developers,
> I have been using Derby for a while, and think the configuration handling code should be improved. In particular, Derby should check the validity of a user-specified configuration value, rather than replacing an invalid value with the default.
> Not sure that is a major issue or not. But at least it happens to me a couple of times, and causes lots of confusion. Thus, I strongly suggest to fix this.
> How to reproduce the problem.
> set:
> derby.storage.pageSize= l2800 ( note the first char is "l" (L), not "1")
> clearly, this invalid value should be notified immediately (or at least logged), however, Derby simply replaces that with the default value, which seems to be "32768". This is a real example, and causes confusion.
> I looked at the code and found the improving code:
> In class PropertyUtil
> public static int handleInt(String value, int min, int max, int defaultValue) {
> if (value == null)
> return defaultValue;
> try {
> int intValue = Integer.parseInt(value);
> if ((intValue >= min) && (intValue <= max))
> return intValue;
> }
> catch (NumberFormatException nfe)
> {
> // just leave the default.
> }
> return defaultValue;
> }
> I would suggest to add logging statements for the invalid cases, and produce an error message to indicate which configuration value is incorrect.
> I have a few more such cases, if you are interested in improving the code, I am happy to share that too.
> Please let me know your thought.
> -Sai
--
This message was sent by Atlassian JIRA
(v6.2#6252)