hazelcast-cpp-client
hazelcast-cpp-client copied to clipboard
Assertion Failure is Fixed [API-1501]
solves this issue
Windows test FAILed.
Linux test FAILed.
verify
verify
Windows test PASSed.
Linux test PASSed.
Windows test PASSed.
Linux test PASSed.
Because TTL has to be an integer it can't be less than 1, 0 is infinite, I had to add 1 second sleep. Before the fix, this test would give an assertion error, should pass without problems after the fix.
Windows test FAILed.
Linux test PASSed.
Windows test PASSed.
Linux test PASSed.
Windows test PASSed.
Linux test PASSed.
I have reviewev the PR and here are my findings :
- Firstly, the fix is correct so it works.
But I don't think it is a good implementation because we call emplace
function 3 times. Indeed, there is no need for that, it can be handled with only one emplace operation.
- Add copy assignment special member function to the
session_state
class.
// cp_impl.h#96
session_state& operator=(const session_state& rhs);
- Make definition of it as :
// cp_impl.cpp
proxy_session_manager::session_state&
proxy_session_manager::session_state::operator=(const session_state& rhs)
{
id = rhs.id;
ttl = rhs.ttl;
creation_time = rhs.creation_time;
acquire_count = rhs.acquire_count.load();
return *this;
}
- Define
create_new_session
like this. If there is already an entry at thesessions_
with the specifiedgroup_id
, then just assign brand-newsession_state
to thevalue
of it.
// the lock_ is already acquired as write lock
auto response = request_new_session(group_id);
session_state state { response.id , response.ttl_millis };
auto result = sessions_.emplace( group_id, state );
if(!result.second)
result.first->second = state;
schedule_heartbeat_task(response.heartbeat_millis);
return result.first;