docs: private BytesRef validateEditedEntry(byte[] retryDataBuffer) {
          BytesRef result = new BytesRef();
  
          byte closeBrace = '}';
          byte newline = '\n';
  
          int newlines = 0;
          for (byte b : retryDataBuffer) {
              if (b == newline) {
                  newlines++;
              }
          }
  
          result.add(retryDataBuffer);
  
          // Check to make sure that either the last byte is a closed brace or a new line.
          byte lastByte = retryDataBuffer[retryDataBuffer.length - 1];
          if (lastByte == newline) {
              // If last byte is a newline, make sure there are two newlines present in the data
              if (newlines != 2) {
                  throw new EsHadoopIllegalArgumentException("Encountered malformed data entry for bulk write retry. " +
                          "Data contains [" + newlines + "] newline characters (\\n) but expected to have [2].");
              }
          } else if (lastByte == closeBrace) {
              // If the last byte is a closed brace, make sure there is only one newline in the data
              if (newlines != 1) {
                  throw new EsHadoopIllegalArgumentException("Encountered malformed data entry for bulk write retry. " +
                          "Data contains [" + newlines + "] newline characters (\\n) but expected to have [1].");
              }
  
              // Add a newline to the entry in this case.
              byte[] trailingNewline = new byte[]{newline};
              result.add(trailingNewline);
          }
          // Further checks are probably intrusive to performance
          return result;
      }