[Libreoffice-commits] core.git: unotools/qa unotools/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 30 09:31:24 UTC 2021


 unotools/qa/complex/tempfile/Test01.java     |    2 ++
 unotools/qa/complex/tempfile/TestHelper.java |    1 +
 unotools/source/ucbhelper/xtempfile.cxx      |    7 ++++++-
 3 files changed, 9 insertions(+), 1 deletion(-)

New commits:
commit ecea9c42d5f1a5e63493fcd92944bd49fb91b338
Author:     Noel Grandin <noel at peralex.com>
AuthorDate: Wed Jun 30 10:30:25 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jun 30 11:30:49 2021 +0200

    fix failure in JunitTest_unotools_complex
    
    Temp files created from OTempFileService are always opened with StreamMode::SHARE_DENYALL.
    So normally you can't open them twice.
    
    But the JunitTest_unotools_complex unit test used to work because it exploited a pessimisation in OTempFileService,
    where that code would close the file when we read to the end.
    
    Which meant that the unit test could open it again and read it.
    
    However, in
        commit 218f36dd614cf828e949f605faaf6a6fd615da26
        Date:   Sun Jun 20 18:51:12 2021 +0200
        tdf#135316 remove OTempFileService pessimisation
    I removed that pessimisation.
    
    So make the share mode a little more permissive.
    
    Change-Id: I297a5c9c0505816b399fad29414077d03231ec72
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118146
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/unotools/qa/complex/tempfile/Test01.java b/unotools/qa/complex/tempfile/Test01.java
index f93b02186e8d..ca81e1801bef 100644
--- a/unotools/qa/complex/tempfile/Test01.java
+++ b/unotools/qa/complex/tempfile/Test01.java
@@ -51,6 +51,8 @@ public class Test01 {
         //compare the file name with the name in the URL.
         sFileURL = m_aTestHelper.GetTempFileURL( xTempFile );
         sFileName = m_aTestHelper.GetTempFileName( xTempFile );
+        m_aTestHelper.Message( "Tempfile URL: " + sFileURL );
+        m_aTestHelper.Message( "Tempfile name: " + sFileName );
         m_aTestHelper.CompareFileNameAndURL( sFileName, sFileURL );
 
         //write to the stream using the service.
diff --git a/unotools/qa/complex/tempfile/TestHelper.java b/unotools/qa/complex/tempfile/TestHelper.java
index 821c33da054b..9ea42b102673 100644
--- a/unotools/qa/complex/tempfile/TestHelper.java
+++ b/unotools/qa/complex/tempfile/TestHelper.java
@@ -78,6 +78,7 @@ public class TestHelper {
     public void ReadDirectlyFromTempFile( byte [][] pBytes, int nBytes,  XSimpleFileAccess xSFA, String sTempFileURL )
          throws java.lang.Exception
     {
+        Message ( "Attempting to read directly from " + sTempFileURL );
         XInputStream xInTemp = xSFA.openFileRead( sTempFileURL );
         if ( xInTemp == null )
             throw new java.lang.Exception("Cannot create input stream from URL.");
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index 0cc0d8904bac..d0f566c9e26c 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -234,7 +234,12 @@ void OTempFileService::checkError () const
 void OTempFileService::checkConnected ()
 {
     if (!mpStream && mpTempFile)
-        mpStream = mpTempFile->GetStream( StreamMode::STD_READWRITE );
+    {
+        // Ideally we should open this SHARE_DENYALL, but the JunitTest_unotools_complex test wants to open
+        // this file directly and read from it.
+        mpStream = mpTempFile->GetStream(StreamMode::READ | StreamMode::WRITE
+                                         | StreamMode::SHARE_DENYWRITE);
+    }
 
     if (!mpStream)
         throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );


More information about the Libreoffice-commits mailing list