summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-10-04 17:16:59 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2022-03-09 19:00:30 +0100
commit7399b1eb25a1a856a1e203bcfb6267a14a1ed70e (patch)
tree990269108649f05bc275bcbf99443d54e8579489 /comphelper
parent59f4780a113bd7bf8cbec08f3ec30c7f620e0b88 (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> (cherry picked from commit 1a3b3eda6ca1c8e063ba6db9e9f34f999ec92c49)
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/streaming/seqoutputstreamserv.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/comphelper/source/streaming/seqoutputstreamserv.cxx b/comphelper/source/streaming/seqoutputstreamserv.cxx
index cadc691c8f03..757df72c3f58 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()
{
::osl::MutexGuard 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;
}