Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 068F1DB6C for ; Thu, 30 Aug 2012 23:41:08 +0000 (UTC) Received: (qmail 18472 invoked by uid 500); 30 Aug 2012 23:41:07 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 18438 invoked by uid 500); 30 Aug 2012 23:41:07 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-issues@hadoop.apache.org Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 18429 invoked by uid 99); 30 Aug 2012 23:41:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Aug 2012 23:41:07 +0000 Date: Fri, 31 Aug 2012 10:41:07 +1100 (NCT) From: "Bo Wang (JIRA)" To: common-issues@hadoop.apache.org Message-ID: <1997718253.19182.1346370067629.JavaMail.jiratomcat@arcas> In-Reply-To: <1434097047.19173.1346369948334.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (HADOOP-8750) Configuration.getClasses never returns default value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HADOOP-8750?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Bo Wang updated HADOOP-8750: ---------------------------- Description: getClasses method in Configuration never returns defaultValue even if the classnames is not set in Configuration. public Class[] getClasses(String name, Class ... defaultValue) { String[] classnames = getTrimmedStrings(name); if (classnames == null) return defaultValue; // Load and return classes using classnames... (omitted) } This is because the condition "if (classnames == null)" is always True. If name is not set in Configuration, classnames will be an empty array (but not null). To fix it, just change the condition to "if (classnames == null || classnames.length == 0)" was: getClasses method in Configuration never returns defaultValue even if the classnames is not set in Configuration. public Class[] getClasses(String name, Class ... defaultValue) { String[] classnames = getTrimmedStrings(name); if (classnames == null) return defaultValue; // Load and return classes using classnames... (omitted) } This is because the condition "if (classnames == null)" is always True. If name is not set in Configuration, classnames will be an empty array (but not null). To fix it, just change the condition to "if (classnames == null || classnames.length == 0)" > Configuration.getClasses never returns default value > ---------------------------------------------------- > > Key: HADOOP-8750 > URL: https://issues.apache.org/jira/browse/HADOOP-8750 > Project: Hadoop Common > Issue Type: Bug > Reporter: Bo Wang > Assignee: Bo Wang > > getClasses method in Configuration never returns defaultValue even if the classnames is not set in Configuration. > public Class[] getClasses(String name, Class ... defaultValue) { > String[] classnames = getTrimmedStrings(name); > if (classnames == null) > return defaultValue; > // Load and return classes using classnames... (omitted) > } > This is because the condition "if (classnames == null)" is always True. If name is not set in Configuration, classnames will be an empty array (but not null). > To fix it, just change the condition to "if (classnames == null || classnames.length == 0)" -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira