comphelper/source/streaming/seqoutputstreamserv.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
New commits: commit 1a3b3eda6ca1c8e063ba6db9e9f34f999ec92c49 Author: Michael Stahl <[email protected]> AuthorDate: Mon Oct 4 17:16:59 2021 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Mon Nov 1 18:13:23 2021 +0100 comphelper: fix SequenceOutputStreamService::getWrittenBytes() With com.sun.star.io.Pipe, you must call closeOutput() or reading from the other end will block forever. If you use com.sun.star.io.SequenceOutputStream, you can't read the output after calling closeOutput() on it because for no good reason it throws a NotConnectedException. Let's just fix it so that a sequence of closeOutput() then getWrittenBytes() returns the finished buffer. Change-Id: Ia6ce28ec05e00e5f1c703dea8669e0271c0b9c20 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123057 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/comphelper/source/streaming/seqoutputstreamserv.cxx b/comphelper/source/streaming/seqoutputstreamserv.cxx index d1ffc4df2d42..84900014aad4 100644 --- a/comphelper/source/streaming/seqoutputstreamserv.cxx +++ b/comphelper/source/streaming/seqoutputstreamserv.cxx @@ -112,6 +112,7 @@ void SAL_CALL SequenceOutputStreamService::closeOutput() if ( !m_xOutputStream.is() ) throw io::NotConnectedException(); + m_xOutputStream->flush(); m_xOutputStream->closeOutput(); m_xOutputStream.clear(); } @@ -120,10 +121,13 @@ void SAL_CALL SequenceOutputStreamService::closeOutput() uno::Sequence< ::sal_Int8 > SAL_CALL SequenceOutputStreamService::getWrittenBytes() { std::scoped_lock aGuard( m_aMutex ); - if ( !m_xOutputStream.is() ) - throw io::NotConnectedException(); - m_xOutputStream->flush(); + if (m_xOutputStream.is()) + { + m_xOutputStream->flush(); + } + // else: no exception, just return the finished sequence + return m_aSequence; }
