code: private Block getBlockInfo(LocatedBlock locatedblock) throws IOException {
      if (locatedblock == null || locatedblock.getLocations().length == 0) {
        return null;
      }
      int replicaNotFoundCount = locatedblock.getLocations().length;
  
      for(DatanodeInfo datanode : locatedblock.getLocations()) {
        ProtocolProxy<ClientDatanodeProtocol> cdp = null;
  
        try {
          cdp = DFSClient.createClientDNProtocolProxy(datanode,
              dfsClient.conf, dfsClient.socketTimeout);
  
          final Block newBlock;
          if (cdp.isMethodSupported("getBlockInfo", int.class, Block.class)) {
            newBlock = cdp.getProxy().getBlockInfo(
                dfsClient.namespaceId, locatedblock.getBlock());
          } else {
            newBlock = cdp.getProxy().getBlockInfo(locatedblock.getBlock());
          }
  
          if (newBlock == null) {
            // special case : replica might not be on the DN, treat as 0 length
            replicaNotFoundCount--;
          } else {
            return newBlock;
          }
        }
        catch(IOException ioe) {
          if (DFSClient.LOG.isDebugEnabled()) {
            DFSClient.LOG.debug("Failed to getBlockInfo from datanode "
                + datanode + " for block " + locatedblock.getBlock(), ioe);
          }
        } finally {
          if (cdp != null) {
            RPC.stopProxy(cdp.getProxy());
          }
        }
      }
  
      // Namenode told us about these locations, but none know about the replica
      // means that we hit the race between pipeline creation start and end.
      // we require all because some other exception could have happened
      // on a DN that has it.  we want to report that error
      if (replicaNotFoundCount == 0) {
        DFSClient.LOG
            .warn("Cannot get block info from any datanode having block "
                + locatedblock.getBlock() + " for file " + src);
        return null;
      }
  
      throw new IOException("Cannot obtain block info for " + locatedblock);
    }
docs: Get block info from a datanode