Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D2942200CFE for ; Fri, 25 Aug 2017 07:49:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D117E16A047; Fri, 25 Aug 2017 05:49:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 21E0316A039 for ; Fri, 25 Aug 2017 07:49:05 +0200 (CEST) Received: (qmail 72153 invoked by uid 500); 25 Aug 2017 05:49:04 -0000 Mailing-List: contact common-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-dev@hadoop.apache.org Received: (qmail 72136 invoked by uid 99); 25 Aug 2017 05:49:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Aug 2017 05:49:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id A248F1806DB for ; Fri, 25 Aug 2017 05:49:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id z3lrFHS-4sQG for ; Fri, 25 Aug 2017 05:49:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 616E35F1EF for ; Fri, 25 Aug 2017 05:49:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 714BCE0E3D for ; Fri, 25 Aug 2017 05:49:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 92DC72538B for ; Fri, 25 Aug 2017 05:49:00 +0000 (UTC) Date: Fri, 25 Aug 2017 05:49:00 +0000 (UTC) From: "hu xiaodong (JIRA)" To: common-dev@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (HADOOP-14807) should prevent the possibility of NPE about ReconfigurableBase.java MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 25 Aug 2017 05:49:07 -0000 hu xiaodong created HADOOP-14807: ------------------------------------ Summary: should prevent the possibility of NPE about ReconfigurableBase.java Key: HADOOP-14807 URL: https://issues.apache.org/jira/browse/HADOOP-14807 Project: Hadoop Common Issue Type: Improvement Reporter: hu xiaodong Assignee: hu xiaodong Priority: Minor 1. {code:title=ReconfigurationThread.java|borderStyle=solid} protected String reconfigurePropertyImpl(String property, String newVal) throws ReconfigurationException { final DatanodeManager datanodeManager = namesystem.getBlockManager() .getDatanodeManager(); if (property.equals(DFS_HEARTBEAT_INTERVAL_KEY)) { return reconfHeartbeatInterval(datanodeManager, property, newVal); } else if (property.equals(DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY)) { return reconfHeartbeatRecheckInterval(datanodeManager, property, newVal); } else if (property.equals(FS_PROTECTED_DIRECTORIES)) { return reconfProtectedDirectories(newVal); } else if (property.equals(HADOOP_CALLER_CONTEXT_ENABLED_KEY)) { return reconfCallerContextEnabled(newVal); } else if (property.equals(ipcClientRPCBackoffEnable)) { return reconfigureIPCBackoffEnabled(newVal); } //======================================================= //here may throw a ReconfigurationException which getCause() is null //======================================================= else { throw new ReconfigurationException(property, newVal, getConf().get( property)); } } {code} 2. {code:title=ReconfigurationThread.java|borderStyle=solid} private static class ReconfigurationThread extends Thread { private ReconfigurableBase parent; ReconfigurationThread(ReconfigurableBase base) { this.parent = base; } // See {@link ReconfigurationServlet#applyChanges} public void run() { LOG.info("Starting reconfiguration task."); final Configuration oldConf = parent.getConf(); final Configuration newConf = parent.getNewConf(); final Collection changes = parent.getChangedProperties(newConf, oldConf); Map> results = Maps.newHashMap(); ConfigRedactor oldRedactor = new ConfigRedactor(oldConf); ConfigRedactor newRedactor = new ConfigRedactor(newConf); for (PropertyChange change : changes) { String errorMessage = null; String oldValRedacted = oldRedactor.redact(change.prop, change.oldVal); String newValRedacted = newRedactor.redact(change.prop, change.newVal); if (!parent.isPropertyReconfigurable(change.prop)) { LOG.info(String.format( "Property %s is not configurable: old value: %s, new value: %s", change.prop, oldValRedacted, newValRedacted)); continue; } LOG.info("Change property: " + change.prop + " from \"" + ((change.oldVal == null) ? "" : oldValRedacted) + "\" to \"" + ((change.newVal == null) ? "" : newValRedacted) + "\"."); try { String effectiveValue = parent.reconfigurePropertyImpl(change.prop, change.newVal); if (change.newVal != null) { oldConf.set(change.prop, effectiveValue); } else { oldConf.unset(change.prop); } } catch (ReconfigurationException e) { //=============================================== // here may occurs NPE, because e.getCause() may be null. //=============================================== errorMessage = e.getCause().getMessage(); } results.put(change, Optional.fromNullable(errorMessage)); } synchronized (parent.reconfigLock) { parent.endTime = Time.now(); parent.status = Collections.unmodifiableMap(results); parent.reconfigThread = null; } } } {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-dev-help@hadoop.apache.org