OpenSearch/modules
Jay Modi 30ab8739a6 Closing a ReleasableBytesStreamOutput closes the underlying BigArray (#23941)
This commit makes closing a ReleasableBytesStreamOutput release the underlying BigArray so
that we can use try-with-resources with these streams and avoid leaking memory by not returning
the BigArray. As part of this change, the ReleasableBytesStreamOutput adds protection to only
release the BigArray once.

In order to make some of the changes cleaner, the ReleasableBytesStream interface has been
removed. The BytesStream interface is changed to a abstract class so that we can use it as a
useable return type for a new method, Streams#flushOnCloseStream. This new method wraps a
given stream and overrides the close method so that the stream is simply flushed and not closed.
This behavior is used in the TcpTransport when compression is used with a
ReleasableBytesStreamOutput as we need to close the compressed stream to ensure all of the data
is written from this stream. Closing the compressed stream will try to close the underlying stream
but we only want to flush so that all of the written bytes are available.

Additionally, an error message method added in the BytesRestResponse did not use a builder
provided by the channel and instead created its own JSON builder. This changes that method to use
the channel builder and in turn the bytes stream output that is managed by the channel.

Note, this commit differs from 6bfecdf921 in that it updates
ReleasableBytesStreamOutput to handle the case of the BigArray decreasing in size, which changes
the reference to the BigArray. When the reference is changed, the releasable needs to be updated
otherwise there could be a leak of bytes and corruption of data in unrelated streams.

This reverts commit afd45c1432, which reverted #23572.
2017-04-14 10:50:31 -04:00
..
aggs-matrix-stats [TEST] improve yaml test sections parsing (#23407) 2017-03-02 12:43:20 +01:00
ingest-common Rename random ASCII helper methods 2017-04-04 11:04:18 -04:00
lang-expression Move getProperty method out of MultiBucketsAggregation.Bucket interface (#23988) 2017-04-10 13:35:01 +02:00
lang-mustache Rename random ASCII helper methods 2017-04-04 11:04:18 -04:00
lang-painless Skip two Painless branch tests on Windows 2017-04-11 06:19:42 -04:00
percolator Removes version 2.x constants from Version (#24011) 2017-04-11 08:31:22 +01:00
reindex Simplify BulkProcessor handling and retry logic (#24051) 2017-04-13 14:48:52 -05:00
repository-url Rename random ASCII helper methods 2017-04-04 11:04:18 -04:00
transport-netty4 Closing a ReleasableBytesStreamOutput closes the underlying BigArray (#23941) 2017-04-14 10:50:31 -04:00
build.gradle Build: Change `gradle run` to use zip distribution (#21001) 2016-10-18 11:48:58 -07:00