Fix coverity issue 236044 (uncaught exception in C++ RSA)
The uncaught exception was a bug in the SharedPromiseState, which threw an exception if a promise
was resolved more than one time.
@@ -923,9 +923,7 @@ void celix::impl::SharedPromiseState<T>::complete(std::unique_lock<std::mutex>&
if (!lck.owns_lock()) {
lck.lock();
}
- if (done) {
- throw celix::PromiseInvocationException("Promise is already resolved");
- }
+ if (!done) {
done = true;
cond.notify_all();
while (!chain.empty()) {
@@ -939,14 +937,13 @@ void celix::impl::SharedPromiseState<T>::complete(std::unique_lock<std::mutex>&
lck.lock();
}
}
+}
inline void celix::impl::SharedPromiseState<void>::complete(std::unique_lock<std::mutex>& lck) {
if (!lck.owns_lock()) {
lck.lock();
}
- if (done) {
- throw celix::PromiseInvocationException("Promise is already resolved");
- }
+ if (!done) {
done = true;
cond.notify_all();
while (!chain.empty()) {
@@ -960,3 +957,4 @@ inline void celix::impl::SharedPromiseState<void>::complete(std::unique_lock<std
lck.lock();
}
}
+}
\ No newline at end of file
