@Override
    public void close() throws IOException {
      super.close();

      final BufferExposingByteArrayOutputStream _out = (BufferExposingByteArrayOutputStream)out;
      final int attributeValueSize = _out.size();
      checkAttributeValueSize(attribute, attributeValueSize);

      lock.writeLock().lock();
      try {
        if (inlineAttributes && attributeValueSize < INLINE_ATTRIBUTE_SMALLER_THAN) {
          //if attribute value could be stored in the directory record inline -> try to (over)write it
          // there:
          rewriteDirectoryRecordWithInlineAttrContent(_out);
        }
        else {
          //if current attribute value can't be stored in directory record -> first remove it from
          //   directory record if it was stored there before:
          int attributeRecordId = findAttributePage(connection, fileId, attribute, true);
          if (inlineAttributes && attributeRecordId < 0) {
            //attribute was stored inline in directory record -> remove it from there it is now:
            rewriteDirectoryRecordWithInlineAttrContent(new BufferExposingByteArrayOutputStream());
            //now, as entry was removed from directory record, .findAttributePage() must create dedicated
            // record for our attribute, and return its recordId:
            attributeRecordId = findAttributePage(connection, fileId, attribute, /* toWrite: */true);
          }

          if (bulkAttrReadSupport) {
            BufferExposingByteArrayOutputStream stream = new BufferExposingByteArrayOutputStream();
            out = stream;
            writeRecordHeader(connection.getAttributeId(attribute.getId()), fileId, this);
            write(_out.getInternalBuffer(), 0, _out.size());
            attributesBlobStorage.writeBytes(attributeRecordId, stream.toByteArraySequence(), attribute.isFixedSize());
          }
          else {
            attributesBlobStorage.writeBytes(attributeRecordId, _out.toByteArraySequence(), attribute.isFixedSize());
          }
        }
      }
      catch (Throwable t) {
        FSRecords.LOG.warn("Error storing " + attribute + " of file(" + fileId + ")");
        throw FSRecords.handleError(t);
      }
      finally {
        lock.writeLock().unlock();
      }
    }
@Override
    public void close()