Source:
<code>public void testServerDefaultsWithMinimalCaching() throws Exception { Configuration clusterConf = new HdfsConfiguration(); long originalBlockSize = DFS_BLOCK_SIZE_DEFAULT * 2; clusterConf.setLong(DFS_BLOCK_SIZE_KEY, originalBlockSize); MiniDFSCluster cluster = new MiniDFSCluster.Builder(clusterConf) .numDataNodes(0) .build(); cluster.waitActive(); FSNamesystem spyNamesystem = NameNodeAdapter.spyOnNamesystem(cluster.getNameNode()); InetSocketAddress nameNodeAddr = cluster.getNameNode().getNameNodeAddress(); try { Configuration clientConf = new HdfsConfiguration(); clientConf.setLong(DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_KEY, 0L); DFSClient dfsClient = new DFSClient(nameNodeAddr, clientConf); FsServerDefaults defaults = dfsClient.getServerDefaults(); assertEquals(originalBlockSize, defaults.getBlockSize()); long updatedDefaultBlockSize = DFS_BLOCK_SIZE_DEFAULT * 3; FsServerDefaults newDefaults = new FsServerDefaults(updatedDefaultBlockSize, defaults.getBytesPerChecksum(), defaults.getWritePacketSize(), defaults.getReplication(), defaults.getFileBufferSize(), defaults.getEncryptDataTransfer(), defaults.getTrashInterval(), defaults.getChecksumType(), defaults.getKeyProviderUri(), defaults.getDefaultStoragePolicyId()); doReturn(newDefaults).when(spyNamesystem).getServerDefaults(); GenericTestUtils.waitFor(()->{ try { FsServerDefaults currDef = dfsClient.getServerDefaults(); return (currDef.getBlockSize() == updatedDefaultBlockSize); } catch (IOException e) { return false; } <START> }, 1, 100); <END> } finally { cluster.shutdown(); } }</code><technical_language>wait a longer 100ms</technical_language>

Target:
public void testServerDefaultsWithMinimalCaching() throws Exception { Configuration clusterConf = new HdfsConfiguration(); long originalBlockSize = DFS_BLOCK_SIZE_DEFAULT * 2; clusterConf.setLong(DFS_BLOCK_SIZE_KEY, originalBlockSize); MiniDFSCluster cluster = new MiniDFSCluster.Builder(clusterConf) .numDataNodes(0) .build(); cluster.waitActive(); FSNamesystem spyNamesystem = NameNodeAdapter.spyOnNamesystem(cluster.getNameNode()); InetSocketAddress nameNodeAddr = cluster.getNameNode().getNameNodeAddress(); try { Configuration clientConf = new HdfsConfiguration(); clientConf.setLong(DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_KEY, 0L); DFSClient dfsClient = new DFSClient(nameNodeAddr, clientConf); FsServerDefaults defaults = dfsClient.getServerDefaults(); assertEquals(originalBlockSize, defaults.getBlockSize()); long updatedDefaultBlockSize = DFS_BLOCK_SIZE_DEFAULT * 3; FsServerDefaults newDefaults = new FsServerDefaults(updatedDefaultBlockSize, defaults.getBytesPerChecksum(), defaults.getWritePacketSize(), defaults.getReplication(), defaults.getFileBufferSize(), defaults.getEncryptDataTransfer(), defaults.getTrashInterval(), defaults.getChecksumType(), defaults.getKeyProviderUri(), defaults.getDefaultStoragePolicyId()); doReturn(newDefaults).when(spyNamesystem).getServerDefaults(); GenericTestUtils.waitFor(()->{ try { FsServerDefaults currDef = dfsClient.getServerDefaults(); return (currDef.getBlockSize() == updatedDefaultBlockSize); } catch (IOException e) { return false; } }, 1, 3000); } finally { cluster.shutdown(); } }