/// <summary> /// Verifies that the combined size of the name and value of an xattr is within /// the configured limit. /// </summary> /// <remarks> /// Verifies that the combined size of the name and value of an xattr is within /// the configured limit. Setting a limit of zero disables this check. /// </remarks> private static void CheckXAttrSize(FSDirectory fsd, XAttr xAttr) { if (fsd.GetXattrMaxSize() == 0) { return; } int size = Sharpen.Runtime.GetBytesForString(xAttr.GetName(), Charsets.Utf8).Length; if (xAttr.GetValue() != null) { size += xAttr.GetValue().Length; } if (size > fsd.GetXattrMaxSize()) { throw new HadoopIllegalArgumentException("The XAttr is too big. The maximum combined size of the" + " name and value is " + fsd.GetXattrMaxSize() + ", but the total size is " + size); } }