Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 66507 invoked from network); 27 Aug 2004 09:36:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 27 Aug 2004 09:36:21 -0000 Received: (qmail 15190 invoked by uid 500); 27 Aug 2004 09:36:15 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 15099 invoked by uid 500); 27 Aug 2004 09:36:14 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 15084 invoked by uid 99); 27 Aug 2004 09:36:14 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [192.18.33.10] (HELO exchange.sun.com) (192.18.33.10) by apache.org (qpsmtpd/0.27.1) with SMTP; Fri, 27 Aug 2004 02:36:14 -0700 Received: (qmail 14194 invoked by uid 50); 27 Aug 2004 09:37:55 -0000 Date: 27 Aug 2004 09:37:55 -0000 Message-ID: <20040827093755.14193.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: commons-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 30545] - [configuration] ConfigurationDynaBean X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=30545 [configuration] ConfigurationDynaBean ------- Additional Comments From ricardo.gladwell@btinternet.com 2004-08-27 09:37 ------- I have a question about the behavior of ConfigurationDynaBean. I'm not sure what the intended behavior should be, but looking at the code in the CVS repository makes me think the intent is different from the current behavior. However, it appears this is fairly new code, so I don't know if the problem is in the code behavior or if I am just misinterpreting the intent from the code. In looking at the code, it appears the intent was for the get method to throw an IllegalArgumentException in the case where the desired property does not exist in the backing Configuration instance. This would cause the method to meet the specification of get in the DynaBean interface. However, get only throws the exception if the specified name is null. If the name is non-null but does not exist, then an empty ConfigurationDynaBean is returned. The reason for this is in the call to configuration.subset in the get method. The relevant code is shown below (this is version 1.2 from the CVS repository): // get configuration property Object result = configuration.getProperty(name); if(result == null && name != null) { // otherwise attempt to create bean from configuration subset Configuration subset = configuration.subset(name); if(subset != null) result = new ConfigurationDynaBean(configuration.subset(name)); } If the extracted subset is not null, then a new ConfigurationDynaBean is constructed from that subset. However, I don't think Configuration.subset ever returns null. If no properties from the configuration begin with the specified prefix, then the return value from subset is an empty Configuration, not null (this is true even if the prefix argument is null). Therefore, the "if(subset != null)" test always succeeds in the above code, and result is always set to a new ConfigurationDynaBean. The only way result will remain null is if it is set to null in the initial configuration.getProperty() call, and then if it bypasses the if-clause by having (name == null). Therefore, that is the only case where the exception is thrown. I didn't notice any JUnit test cases for checking the behavior when accessing a non-existing property name (although there is a case for a null name). So, my question is: should the get method throw an exception when called with a non-existent property name? If so, then the get method needs to be changed. If not, I might recommend documenting this difference from the DynaBean interface in some way, and perhaps changing the above code to remove the superfluous if-test. I'd be happy to assist if needed. -- Bill Vollers --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org