[Libreoffice-commits] online.git: loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp loolwsd/Util.hpp

Jan Holesovsky kendy at collabora.com
Tue Jul 19 09:10:47 UTC 2016


 loolwsd/LOOLWSD.cpp |    2 +-
 loolwsd/LOOLWSD.hpp |    2 +-
 loolwsd/Util.hpp    |   19 +++++++------------
 3 files changed, 9 insertions(+), 14 deletions(-)

New commits:
commit 6aae20e2176880e358cd1842ac68cd37bfc1bde3
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jul 19 11:07:07 2016 +0200

    Setting the RuntimeConstant in production should not throw.
    
    It is very bad, but let's not get the production env. down by that.

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index ff36b76..cbd3fca 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1255,7 +1255,7 @@ std::string LOOLWSD::ChildRoot;
 std::string LOOLWSD::ServerName;
 std::string LOOLWSD::FileServerRoot;
 std::string LOOLWSD::LOKitVersion;
-Util::RuntimeCostant<bool> LOOLWSD::SSLEnabled;
+Util::RuntimeConstant<bool> LOOLWSD::SSLEnabled;
 
 static std::string UnitTestLibrary;
 
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 3a0fda6..ff282d6 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -66,7 +66,7 @@ protected:
     int main(const std::vector<std::string>& args) override;
 
 private:
-    static Util::RuntimeCostant<bool> SSLEnabled;
+    static Util::RuntimeConstant<bool> SSLEnabled;
 
     void initializeSSL();
     void displayHelp();
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index 8b866a3..e2dd51b 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -186,13 +186,13 @@ namespace Util
     };
 
     template<typename T>
-    class RuntimeCostant
+    class RuntimeConstant
     {
         T mValue;
         bool mInitialized;
 
     public:
-        RuntimeCostant()
+        RuntimeConstant()
             : mValue()
             , mInitialized(false)
         {}
@@ -205,21 +205,16 @@ namespace Util
             }
             else
             {
-                throw std::runtime_error("RuntimeCostant instance read before being initialized.");
+                throw std::runtime_error("RuntimeConstant instance read before being initialized.");
             }
         }
 
         void set(const T& value)
         {
-            if(mInitialized)
-            {
-                throw std::runtime_error("RuntimeCostant instance already initialized.");
-            }
-            else
-            {
-                mInitialized = true;
-                mValue = value;
-            }
+            assert(!mInitialized);
+
+            mInitialized = true;
+            mValue = value;
         }
     };
 } // end namespace Util


More information about the Libreoffice-commits mailing list