code: @Override
    public void waitForBucketEmpty(String bucketName)
        throws IOException {
      Preconditions.checkArgument(!Strings.isNullOrEmpty(bucketName),
          "bucketName must not be null or empty");
  
      for (int i = 0; i < BUCKET_EMPTY_MAX_RETRIES; i++) {
        // We only need one item to see the bucket is not yet empty.
        List<String> objectNames = listObjectNames(bucketName, null, PATH_DELIMITER, 1);
        if (objectNames.isEmpty()) {
          return;
        }
        try {
          sleeper.sleep(BUCKET_EMPTY_WAIT_TIME_MS);
        } catch (InterruptedException ignored) {
          // Ignore the exception and loop.
        }
      }
      throw new IOException("Internal error: bucket not empty: " + bucketName);
    }
docs: See {@link GoogleCloudStorage#waitForBucketEmpty(String)} for details about expected behavior.