Source:
<code>public void checkDiskError() throws IOException { Set<FsVolumeSpi> unhealthyVolumes; try { unhealthyVolumes = volumeChecker.checkAllVolumes(allData); lastDiskErrorCheck = Time.monotonicNow(); } catch (InterruptedException e) { LOG.error("Interrupted while running disk check", e); throw new IOException("Interrupted while running disk check", e); } if (unhealthyVolumes.size() > 0) { if (errorDisk == null) { errorDisk = new ArrayList<>(); } List<StorageLocation> tmpDisk = Lists.newArrayList(errorDisk); errorDisk = null; for (FsVolumeSpi vol : unhealthyVolumes) { LOG.info("Add error disk " + vol.getStorageLocation() + " to errorDisk - " + vol.getStorageLocation()); <START> errorDisk.add(vol.getStorageLocation()); <END> if (tmpDisk.contains(vol.getStorageLocation())) { tmpDisk.remove(vol.getStorageLocation()); } } LOG.warn("checkDiskError got failed volumes - {}", unhealthyVolumes.size(), unhealthyVolumes); handleVolumeFailures(unhealthyVolumes); if (!tmpDisk.isEmpty()) { try { Configuration conf = getConf(); String newDataDirs = conf.get(DFS_DATANODE_DATA_DIR_KEY) + "," + Joiner.on(",").join(tmpDisk); refreshVolumes(newDataDirs); } catch (IOException e) { LOG.error("Auto refreshVolumes error : ", e); } } } else { LOG.debug("checkDiskError encountered no failures," + "then check errorDisk"); if (errorDisk != null && !errorDisk.isEmpty()) { try { Configuration conf = getConf(); String newDataDirs = conf.get(DFS_DATANODE_DATA_DIR_KEY) + "," + Joiner.on(",").join(errorDisk); refreshVolumes(newDataDirs); errorDisk = null; } catch (IOException e) { LOG.error("Auto refreshVolumes error : ", e); } } } }</code><technical_language>throw NPE set errorDisk=null loop</technical_language>

Target:
public void checkDiskError() throws IOException { Set<FsVolumeSpi> unhealthyVolumes; Configuration conf = getConf(); String newDataDirs = null; try { unhealthyVolumes = volumeChecker.checkAllVolumes(allData); lastDiskErrorCheck = Time.monotonicNow(); } catch (InterruptedException e) { LOG.error("Interrupted while running disk check", e); throw new IOException("Interrupted while running disk check", e); } if (unhealthyVolumes.size() > 0) { if (errorDisk == null) { errorDisk = new ArrayList<>(); } List<StorageLocation> tmpDisk = Lists.newArrayList(errorDisk); errorDisk.clear(); for (FsVolumeSpi vol : unhealthyVolumes) { LOG.info("Add error disk to errorDisk - {}", vol.getStorageLocation(), vol.getStorageLocation()); errorDisk.add(vol.getStorageLocation()); if (tmpDisk.contains(vol.getStorageLocation())) { tmpDisk.remove(vol.getStorageLocation()); } } LOG.warn("checkDiskError got failed volumes - {}", unhealthyVolumes.size(), unhealthyVolumes); handleVolumeFailures(unhealthyVolumes); if (!tmpDisk.isEmpty()) { newDataDirs = conf.get(DFS_DATANODE_DATA_DIR_KEY) + "," + Joiner.on(",").join(tmpDisk); } } else { LOG.debug("checkDiskError encountered no failures," + "then check errorDisk"); if (errorDisk != null && !errorDisk.isEmpty()) { newDataDirs = conf.get(DFS_DATANODE_DATA_DIR_KEY) + "," + Joiner.on(",").join(errorDisk); } } if (newDataDirs != null) { LOG.debug("Bad disks is repaired, should refreshVolumes disk."); try { refreshVolumes(newDataDirs); } catch (IOException e) { LOG.error("Bad disks is repaired, refreshVolumes error : ", e); } } }