mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-28 04:06:59 +00:00
thrift: verify in set_keyspace that the keyspace exists
The original code just assigns value to _ks_name which is a sstring
so the try { } catch { } clause only gave the wrong impression that
something is checked.
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
This commit is contained in:
@@ -111,12 +111,12 @@ public:
|
||||
}
|
||||
|
||||
void set_keyspace(tcxx::function<void()> cob, tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& keyspace) {
|
||||
try {
|
||||
if (!_db.local().has_keyspace(keyspace)) {
|
||||
complete_with_exception<InvalidRequestException>(std::move(exn_cob),
|
||||
"keyspace %s does not exist", keyspace);
|
||||
} else {
|
||||
_ks_name = keyspace;
|
||||
cob();
|
||||
} catch (std::out_of_range& e) {
|
||||
return complete_with_exception<InvalidRequestException>(std::move(exn_cob),
|
||||
"keyspace %s does not exist", keyspace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user