diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-10-04 17:16:59 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-01 18:13:23 +0100 |
commit | 1a3b3eda6ca1c8e063ba6db9e9f34f999ec92c49 (patch) | |
tree | 55b95d0975aea8a28bff2a9e86b03ada140ff352 /comphelper | |
parent | 68a3df2f1282f40fa4accaed21a69a84d76be37d (diff) |
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 <michael.stahl@allotropia.de>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/streaming/seqoutputstreamserv.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
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; } |