AttributeOutputStream (final int fileId, final @NotNull FileAttribute attribute) { //MAYBE RC: check fileId for be in range (1..max)? fileId will be checked on stream.close(), // but it is quite common to swallow exceptions from stream.close() -- and in general // it is better to fail earlier final AttributeOutputStream attributeStream = attributesStorage.writeAttribute(connection, fileId, attribute); if (attribute.isVersioned()) { try { DataInputOutputUtil.writeINT(attributeStream, attribute.getVersion()); } catch (IOException e) { throw new AssertionError("Write to byte[]-backed stream should not throw IOException -- a bug?", e); } } return attributeStream; }