Skip to content

Commit

Permalink
Remove exception specifications
Browse files Browse the repository at this point in the history
C++17 removed exception specifications from the language, and gcc 7 warns
about them even in C++14 mode.  Remove them from the code base.
  • Loading branch information
avikivity committed May 5, 2017
1 parent 5278e1a commit a592573
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 53 deletions.
5 changes: 2 additions & 3 deletions auth/auth.cc
Expand Up @@ -331,14 +331,13 @@ future<bool> auth::auth::is_super_user(const sstring& username) {
});
}

future<> auth::auth::insert_user(const sstring& username, bool is_super)
throw (exceptions::request_execution_exception) {
future<> auth::auth::insert_user(const sstring& username, bool is_super) {
return cql3::get_local_query_processor().process(sprint("INSERT INTO %s.%s (%s, %s) VALUES (?, ?)",
AUTH_KS, USERS_CF, USER_NAME, SUPER),
consistency_for_user(username), { username, is_super }).discard_result();
}

future<> auth::auth::delete_user(const sstring& username) throw(exceptions::request_execution_exception) {
future<> auth::auth::delete_user(const sstring& username) {
return cql3::get_local_query_processor().process(sprint("DELETE FROM %s.%s WHERE %s = ?",
AUTH_KS, USERS_CF, USER_NAME),
consistency_for_user(username), { username }).discard_result();
Expand Down
4 changes: 2 additions & 2 deletions auth/auth.hh
Expand Up @@ -91,15 +91,15 @@ public:
* @param isSuper User's new status.
* @throws RequestExecutionException
*/
static future<> insert_user(const sstring& username, bool is_super) throw(exceptions::request_execution_exception);
static future<> insert_user(const sstring& username, bool is_super);

/**
* Deletes the user from AUTH_KS.USERS_CF.
*
* @param username Username to delete.
* @throws RequestExecutionException
*/
static future<> delete_user(const sstring& username) throw(exceptions::request_execution_exception);
static future<> delete_user(const sstring& username);

/**
* Sets up Authenticator and Authorizer.
Expand Down
10 changes: 5 additions & 5 deletions auth/authenticator.cc
Expand Up @@ -72,7 +72,7 @@ sstring auth::authenticator::option_to_string(option opt) {
static std::unique_ptr<auth::authenticator> global_authenticator;

future<>
auth::authenticator::setup(const sstring& type) throw (exceptions::configuration_exception) {
auth::authenticator::setup(const sstring& type) {
if (auth::auth::is_class_type(type, ALLOW_ALL_AUTHENTICATOR_NAME)) {
class allow_all_authenticator : public authenticator {
public:
Expand All @@ -88,16 +88,16 @@ auth::authenticator::setup(const sstring& type) throw (exceptions::configuration
option_set alterable_options() const override {
return option_set();
}
future<::shared_ptr<authenticated_user>> authenticate(const credentials_map& credentials) const throw(exceptions::authentication_exception) override {
future<::shared_ptr<authenticated_user>> authenticate(const credentials_map& credentials) const override {
return make_ready_future<::shared_ptr<authenticated_user>>(::make_shared<authenticated_user>());
}
future<> create(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override {
future<> create(sstring username, const option_map& options) override {
return make_ready_future();
}
future<> alter(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override {
future<> alter(sstring username, const option_map& options) override {
return make_ready_future();
}
future<> drop(sstring username) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override {
future<> drop(sstring username) override {
return make_ready_future();
}
const resource_ids& protected_resources() const override {
Expand Down
14 changes: 7 additions & 7 deletions auth/authenticator.hh
Expand Up @@ -92,7 +92,7 @@ public:
* For example, use this method to create any required keyspaces/column families.
* Note: Only call from main thread.
*/
static future<> setup(const sstring& type) throw(exceptions::configuration_exception);
static future<> setup(const sstring& type);

/**
* Returns the system authenticator. Must have called setup before calling this.
Expand Down Expand Up @@ -129,7 +129,7 @@ public:
*
* @throws authentication_exception if credentials don't match any known user.
*/
virtual future<::shared_ptr<authenticated_user>> authenticate(const credentials_map& credentials) const throw(exceptions::authentication_exception) = 0;
virtual future<::shared_ptr<authenticated_user>> authenticate(const credentials_map& credentials) const = 0;

/**
* Called during execution of CREATE USER query (also may be called on startup, see seedSuperuserOptions method).
Expand All @@ -141,7 +141,7 @@ public:
* @throws exceptions::request_validation_exception
* @throws exceptions::request_execution_exception
*/
virtual future<> create(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) = 0;
virtual future<> create(sstring username, const option_map& options) = 0;

/**
* Called during execution of ALTER USER query.
Expand All @@ -154,7 +154,7 @@ public:
* @throws exceptions::request_validation_exception
* @throws exceptions::request_execution_exception
*/
virtual future<> alter(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) = 0;
virtual future<> alter(sstring username, const option_map& options) = 0;


/**
Expand All @@ -164,7 +164,7 @@ public:
* @throws exceptions::request_validation_exception
* @throws exceptions::request_execution_exception
*/
virtual future<> drop(sstring username) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) = 0;
virtual future<> drop(sstring username) = 0;

/**
* Set of resources that should be made inaccessible to users and only accessible internally.
Expand All @@ -177,9 +177,9 @@ public:
class sasl_challenge {
public:
virtual ~sasl_challenge() {}
virtual bytes evaluate_response(bytes_view client_response) throw(exceptions::authentication_exception) = 0;
virtual bytes evaluate_response(bytes_view client_response) = 0;
virtual bool is_complete() const = 0;
virtual future<::shared_ptr<authenticated_user>> get_authenticated_user() const throw(exceptions::authentication_exception) = 0;
virtual future<::shared_ptr<authenticated_user>> get_authenticated_user() const = 0;
};

/**
Expand Down
6 changes: 2 additions & 4 deletions auth/data_resource.cc
Expand Up @@ -115,16 +115,14 @@ auth::data_resource auth::data_resource::get_parent() const {
}
}

const sstring& auth::data_resource::keyspace() const
throw (std::invalid_argument) {
const sstring& auth::data_resource::keyspace() const {
if (is_root_level()) {
throw std::invalid_argument("ROOT data resource has no keyspace");
}
return _ks;
}

const sstring& auth::data_resource::column_family() const
throw (std::invalid_argument) {
const sstring& auth::data_resource::column_family() const {
if (!is_column_family_level()) {
throw std::invalid_argument(sprint("%s data resource has no column family", name()));
}
Expand Down
4 changes: 2 additions & 2 deletions auth/data_resource.hh
Expand Up @@ -117,13 +117,13 @@ public:
* @return keyspace of the resource.
* @throws std::invalid_argument if it's the root-level resource.
*/
const sstring& keyspace() const throw(std::invalid_argument);
const sstring& keyspace() const;

/**
* @return column family of the resource.
* @throws std::invalid_argument if it's not a cf-level resource.
*/
const sstring& column_family() const throw(std::invalid_argument);
const sstring& column_family() const;

/**
* @return Whether or not the resource has a parent in the hierarchy.
Expand Down
21 changes: 6 additions & 15 deletions auth/password_authenticator.cc
Expand Up @@ -201,8 +201,7 @@ auth::authenticator::option_set auth::password_authenticator::alterable_options(
}

future<::shared_ptr<auth::authenticated_user> > auth::password_authenticator::authenticate(
const credentials_map& credentials) const
throw (exceptions::authentication_exception) {
const credentials_map& credentials) const {
if (!credentials.count(USERNAME_KEY)) {
throw exceptions::authentication_exception(sprint("Required key '%s' is missing", USERNAME_KEY));
}
Expand Down Expand Up @@ -241,9 +240,7 @@ future<::shared_ptr<auth::authenticated_user> > auth::password_authenticator::au
}

future<> auth::password_authenticator::create(sstring username,
const option_map& options)
throw (exceptions::request_validation_exception,
exceptions::request_execution_exception) {
const option_map& options) {
try {
auto password = boost::any_cast<sstring>(options.at(option::PASSWORD));
auto query = sprint("INSERT INTO %s.%s (%s, %s) VALUES (?, ?)",
Expand All @@ -256,9 +253,7 @@ future<> auth::password_authenticator::create(sstring username,
}

future<> auth::password_authenticator::alter(sstring username,
const option_map& options)
throw (exceptions::request_validation_exception,
exceptions::request_execution_exception) {
const option_map& options) {
try {
auto password = boost::any_cast<sstring>(options.at(option::PASSWORD));
auto query = sprint("UPDATE %s.%s SET %s = ? WHERE %s = ?",
Expand All @@ -270,9 +265,7 @@ future<> auth::password_authenticator::alter(sstring username,
}
}

future<> auth::password_authenticator::drop(sstring username)
throw (exceptions::request_validation_exception,
exceptions::request_execution_exception) {
future<> auth::password_authenticator::drop(sstring username) {
try {
auto query = sprint("DELETE FROM %s.%s WHERE %s = ?",
auth::AUTH_KS, CREDENTIALS_CF, USER_NAME);
Expand Down Expand Up @@ -308,8 +301,7 @@ ::shared_ptr<auth::authenticator::sasl_challenge> auth::password_authenticator::
* would expect
* @throws javax.security.sasl.SaslException
*/
bytes evaluate_response(bytes_view client_response)
throw (exceptions::authentication_exception) override {
bytes evaluate_response(bytes_view client_response) override {
logger.debug("Decoding credentials from client token");

sstring username, password;
Expand Down Expand Up @@ -347,8 +339,7 @@ ::shared_ptr<auth::authenticator::sasl_challenge> auth::password_authenticator::
bool is_complete() const override {
return _complete;
}
future<::shared_ptr<authenticated_user>> get_authenticated_user() const
throw (exceptions::authentication_exception) override {
future<::shared_ptr<authenticated_user>> get_authenticated_user() const override {
return _authenticator.authenticate(_credentials);
}
private:
Expand Down
8 changes: 4 additions & 4 deletions auth/password_authenticator.hh
Expand Up @@ -58,10 +58,10 @@ public:
bool require_authentication() const override;
option_set supported_options() const override;
option_set alterable_options() const override;
future<::shared_ptr<authenticated_user>> authenticate(const credentials_map& credentials) const throw(exceptions::authentication_exception) override;
future<> create(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override;
future<> alter(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override;
future<> drop(sstring username) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override;
future<::shared_ptr<authenticated_user>> authenticate(const credentials_map& credentials) const override;
future<> create(sstring username, const option_map& options) override;
future<> alter(sstring username, const option_map& options) override;
future<> drop(sstring username) override;
const resource_ids& protected_resources() const override;
::shared_ptr<sasl_challenge> new_sasl_challenge() const override;

Expand Down
14 changes: 8 additions & 6 deletions query-result-set.hh
Expand Up @@ -56,27 +56,28 @@ public:
bool has(const sstring& column_name) const {
return _cells.count(column_name) > 0;
}
// Look up a deserialized row cell value by column name.
// Look up a deserialized row cell value by column name; throws no_such_column on error
const data_value&
get_data_value(const sstring& column_name) const throw (no_such_column) {
get_data_value(const sstring& column_name) const {
auto it = _cells.find(column_name);
if (it == _cells.end()) {
throw no_such_column(column_name);
}
return it->second;
}
// Look up a deserialized row cell value by column name.
// Look up a deserialized row cell value by column name; throws no_such_column on error.
template<typename T>
std::experimental::optional<T>
get(const sstring& column_name) const throw (no_such_column) {
get(const sstring& column_name) const {
auto&& value = get_data_value(column_name);
if (value.is_null()) {
return std::experimental::nullopt;
}
return std::experimental::optional<T>{value_cast<T>(value)};
}
// throws no_such_column or null_column_value on error
template<typename T>
T get_nonnull(const sstring& column_name) const throw (no_such_column, null_column_value) {
T get_nonnull(const sstring& column_name) const {
auto v = get<T>(column_name);
if (v) {
return *v;
Expand Down Expand Up @@ -112,7 +113,8 @@ public:
bool empty() const {
return _rows.empty();
}
const result_set_row& row(size_t idx) const throw (std::out_of_range) {
// throws std::out_of_range on error
const result_set_row& row(size_t idx) const {
if (idx >= _rows.size()) {
throw std::out_of_range("no such row in result set: " + std::to_string(idx));
}
Expand Down
2 changes: 1 addition & 1 deletion service/client_state.cc
Expand Up @@ -77,7 +77,7 @@ void service::client_state::validate_login() const {
}
}

void service::client_state::ensure_not_anonymous() const throw(exceptions::unauthorized_exception) {
void service::client_state::ensure_not_anonymous() const {
validate_login();
if (_user->is_anonymous()) {
throw exceptions::unauthorized_exception("You have to be logged in and not anonymous to perform this request");
Expand Down
2 changes: 1 addition & 1 deletion service/client_state.hh
Expand Up @@ -247,7 +247,7 @@ public:
future<> ensure_has_permission(auth::permission, auth::data_resource) const;

void validate_login() const;
void ensure_not_anonymous() const throw(exceptions::unauthorized_exception);
void ensure_not_anonymous() const; // unauthorized_exception on error

#if 0
public void ensureIsSuper(String message) throws UnauthorizedException
Expand Down
6 changes: 3 additions & 3 deletions sstables/hyperloglog.hh
Expand Up @@ -250,7 +250,7 @@ public:
*
* @exception std::invalid_argument number of registers doesn't match.
*/
void merge(const HyperLogLog& other) throw (std::invalid_argument) {
void merge(const HyperLogLog& other) {
if (m_ != other.m_) {
std::stringstream ss;
ss << "number of registers doesn't match: " << m_ << " != " << other.m_;
Expand Down Expand Up @@ -298,7 +298,7 @@ public:
*
* @exception std::runtime_error When failed to dump.
*/
void dump(std::ostream& os) const throw(std::runtime_error){
void dump(std::ostream& os) const {
os.write((char*)&b_, sizeof(b_));
os.write((char*)&M_[0], sizeof(M_[0]) * M_.size());
if(os.fail()){
Expand All @@ -313,7 +313,7 @@ public:
*
* @exception std::runtime_error When failed to restore.
*/
void restore(std::istream& is) throw(std::runtime_error){
void restore(std::istream& is) {
uint8_t b = 0;
is.read((char*)&b, sizeof(b));
HyperLogLog tempHLL(b);
Expand Down

0 comments on commit a592573

Please sign in to comment.