@Override
  public Object[] maskObjects(Logger logger, Object... args) {
    /**
     * This function is to mask MountPOption, and those who are referring to it.
     * If something else need be masked, extra code change is required.
     * And also if a new proto message referring direct/indirect to MountPOption,
     * extra code should be added here.
     */
    Object [] objects = new Object[args.length];
    for (int i = 0; i < args.length; i++) {
      if (args[i] instanceof MountPOptions) {
        MountPOptions.Builder newMP = MountPOptions.newBuilder((MountPOptions) args[i]);
        newMP.clearProperties();
        copyAndMaskProperties(newMP, ((MountPOptions) args[i]).getPropertiesMap());
        objects[i] = newMP.build();
      } else if (args[i] instanceof MountPRequest) {
        MountPRequest.Builder mpR = MountPRequest.newBuilder((MountPRequest) args[i]);
        MountPOptions.Builder newMP = mpR.getOptionsBuilder();
        newMP.clearProperties();
        copyAndMaskProperties(newMP, ((MountPRequest) args[i]).getOptions().getPropertiesMap());
        objects[i] = mpR.build();
      } else if (args[i] instanceof UfsInfo) {
        UfsInfo.Builder ufsInfo = UfsInfo.newBuilder((UfsInfo) args[i]);
        MountPOptions.Builder newMP = ufsInfo.getPropertiesBuilder();
        newMP.clearProperties();
        copyAndMaskProperties(newMP, ((UfsInfo) args[i]).getProperties().getPropertiesMap());
        objects[i] = ufsInfo.build();
      } else if (args[i] instanceof GetUfsInfoPResponse) {
        GetUfsInfoPResponse.Builder getUfsInfoResponse =
            GetUfsInfoPResponse.newBuilder((GetUfsInfoPResponse) args[i]);
        MountPOptions.Builder newMP = getUfsInfoResponse.getUfsInfoBuilder().getPropertiesBuilder();
        newMP.clearProperties();
        copyAndMaskProperties(newMP,
            ((GetUfsInfoPResponse) args[i]).getUfsInfo().getProperties().getPropertiesMap());
        objects[i] = getUfsInfoResponse.build();
      } else if (args[i] instanceof UpdateMountPRequest) {
        UpdateMountPRequest.Builder updateMountPRequest =
            UpdateMountPRequest.newBuilder((UpdateMountPRequest) args[i]);
        MountPOptions.Builder newMP = updateMountPRequest.getOptionsBuilder();
        newMP.clearProperties();
        copyAndMaskProperties(newMP, ((UpdateMountPRequest) args[i])
            .getOptions().getPropertiesMap());
        objects[i] = updateMountPRequest.build();
      } else {
        objects[i] = args[i];
      }
    }

    return objects;
  }
@Test
  public void maskObjectsAll() {
    {
      MountPOptions.Builder mpb = MountPOptions.newBuilder();
      mpb.putProperties("key1", "value1");
      mpb.putProperties(PropertyKey.Name.S3A_ACCESS_KEY, "mycredential");
      String result = String.format("{%s}",
          RpcSensitiveConfigMask.CREDENTIAL_FIELD_MASKER.maskObjects(null, mpb.build()));
      Assert.assertEquals(true, result.contains("key1"));
      Assert.assertEquals(true, result.contains("value1"));
      Assert.assertEquals(true, result.contains("Masked"));
      Assert.assertEquals(true, result.contains(PropertyKey.Name.S3A_ACCESS_KEY));
      Assert.assertEquals(false, result.contains("mycredential"));
    }

    {
      MountPRequest.Builder obj = MountPRequest.newBuilder();
      MountPOptions.Builder mpb = obj.getOptionsBuilder();
      mpb.putProperties("key1", "value1");
      mpb.putProperties(PropertyKey.Name.S3A_ACCESS_KEY, "mycredential");
      String result = String.format("{%s}",
          RpcSensitiveConfigMask.CREDENTIAL_FIELD_MASKER.maskObjects(null, obj.build()));
      Assert.assertEquals(true, result.contains("key1"));
      Assert.assertEquals(true, result.contains("value1"));
      Assert.assertEquals(true, result.contains("Masked"));
      Assert.assertEquals(true, result.contains(PropertyKey.Name.S3A_ACCESS_KEY));
      Assert.assertEquals(false, result.contains("mycredential"));
    }

    {
      UfsInfo.Builder obj = UfsInfo.newBuilder();
      MountPOptions.Builder mpb = obj.getPropertiesBuilder();
      mpb.putProperties("key1", "value1");
      mpb.putProperties(PropertyKey.Name.S3A_ACCESS_KEY, "mycredential");
      String result = String.format("{%s}",
          RpcSensitiveConfigMask.CREDENTIAL_FIELD_MASKER.maskObjects(null, obj.build()));
      Assert.assertEquals(true, result.contains("key1"));
      Assert.assertEquals(true, result.contains("value1"));
      Assert.assertEquals(true, result.contains("Masked"));
      Assert.assertEquals(true, result.contains(PropertyKey.Name.S3A_ACCESS_KEY));
      Assert.assertEquals(false, result.contains("mycredential"));
    }

    {
      GetUfsInfoPResponse.Builder obj = GetUfsInfoPResponse.newBuilder();
      MountPOptions.Builder mpb = obj.getUfsInfoBuilder().getPropertiesBuilder();
      mpb.putProperties("key1", "value1");
      mpb.putProperties(PropertyKey.Name.S3A_ACCESS_KEY, "mycredential");
      String result = String.format("{%s}",
          RpcSensitiveConfigMask.CREDENTIAL_FIELD_MASKER.maskObjects(null, obj.build()));
      Assert.assertEquals(true, result.contains("key1"));
      Assert.assertEquals(true, result.contains("value1"));
      Assert.assertEquals(true, result.contains("Masked"));
      Assert.assertEquals(true, result.contains(PropertyKey.Name.S3A_ACCESS_KEY));
      Assert.assertEquals(false, result.contains("mycredential"));
    }

    {
      UpdateMountPRequest.Builder obj = UpdateMountPRequest.newBuilder();
      MountPOptions.Builder mpb = obj.getOptionsBuilder();
      mpb.putProperties("key1", "value1");
      mpb.putProperties(PropertyKey.Name.S3A_ACCESS_KEY, "mycredential");
      String result = String.format("{%s}",
          RpcSensitiveConfigMask.CREDENTIAL_FIELD_MASKER.maskObjects(null, obj.build()));
      Assert.assertEquals(true, result.contains("key1"));
      Assert.assertEquals(true, result.contains("value1"));
      Assert.assertEquals(true, result.contains("Masked"));
      Assert.assertEquals(true, result.contains(PropertyKey.Name.S3A_ACCESS_KEY));
      Assert.assertEquals(false, result.contains("mycredential"));
    }

    {
      String astr = "astr";

      String result = String.format("{%s}",
          RpcSensitiveConfigMask.CREDENTIAL_FIELD_MASKER.maskObjects(null, astr));
      Assert.assertEquals(false, result.contains("mycredential"));
      Assert.assertEquals(false, result.contains("Masked"));
      Assert.assertEquals(true, result.contains(astr));
    }
  }