#538 prevent destructors from throwing exceptions

This commit is contained in:
Guenter Obiltschnig 2014-09-19 10:13:03 +02:00
parent 5a14f72508
commit 85fd968a1e
11 changed files with 100 additions and 24 deletions

View File

@ -84,9 +84,16 @@ struct MySQL_API MySQLConnectorRegistrator
~MySQLConnectorRegistrator() ~MySQLConnectorRegistrator()
/// Calls Poco::Data::MySQL::unregisterConnector(); /// Calls Poco::Data::MySQL::unregisterConnector();
{
try
{ {
Poco::Data::MySQL::Connector::unregisterConnector(); Poco::Data::MySQL::Connector::unregisterConnector();
} }
catch (...)
{
poco_unexpected();
}
}
}; };

View File

@ -95,9 +95,16 @@ struct ODBC_API ODBCConnectorRegistrator
~ODBCConnectorRegistrator() ~ODBCConnectorRegistrator()
/// Calls Poco::Data::ODBC::unregisterConnector(); /// Calls Poco::Data::ODBC::unregisterConnector();
{
try
{ {
Poco::Data::ODBC::Connector::unregisterConnector(); Poco::Data::ODBC::Connector::unregisterConnector();
} }
catch (...)
{
poco_unexpected();
}
}
}; };

View File

@ -57,6 +57,8 @@ public:
~Handle() ~Handle()
/// Destroys the Handle. /// Destroys the Handle.
{ {
try
{
#if defined(_DEBUG) #if defined(_DEBUG)
SQLRETURN rc = SQLRETURN rc =
#endif #endif
@ -65,6 +67,11 @@ public:
// leak resources. So, we throw here in debug mode if things go bad. // leak resources. So, we throw here in debug mode if things go bad.
poco_assert_dbg (!Utility::isError(rc)); poco_assert_dbg (!Utility::isError(rc));
} }
catch (...)
{
poco_unexpected();
}
}
operator const H& () const operator const H& () const
/// Const conversion operator into reference to native type. /// Const conversion operator into reference to native type.

View File

@ -39,6 +39,8 @@ ConnectionHandle::ConnectionHandle(EnvironmentHandle* pEnvironment):
ConnectionHandle::~ConnectionHandle() ConnectionHandle::~ConnectionHandle()
{
try
{ {
SQLDisconnect(_hdbc); SQLDisconnect(_hdbc);
SQLRETURN rc = SQLFreeHandle(SQL_HANDLE_DBC, _hdbc); SQLRETURN rc = SQLFreeHandle(SQL_HANDLE_DBC, _hdbc);
@ -47,6 +49,11 @@ ConnectionHandle::~ConnectionHandle()
poco_assert (!Utility::isError(rc)); poco_assert (!Utility::isError(rc));
} }
catch (...)
{
poco_unexpected();
}
}
} } } // namespace Poco::Data::ODBC } } } // namespace Poco::Data::ODBC

View File

@ -40,10 +40,17 @@ EnvironmentHandle::EnvironmentHandle(): _henv(SQL_NULL_HENV)
EnvironmentHandle::~EnvironmentHandle() EnvironmentHandle::~EnvironmentHandle()
{
try
{ {
SQLRETURN rc = SQLFreeHandle(SQL_HANDLE_ENV, _henv); SQLRETURN rc = SQLFreeHandle(SQL_HANDLE_ENV, _henv);
poco_assert (!Utility::isError(rc)); poco_assert (!Utility::isError(rc));
} }
catch (...)
{
poco_unexpected();
}
}
} } } // namespace Poco::Data::ODBC } } } // namespace Poco::Data::ODBC

View File

@ -51,9 +51,16 @@ Preparator::Preparator(const Preparator& other):
Preparator::~Preparator() Preparator::~Preparator()
{
try
{ {
freeMemory(); freeMemory();
} }
catch (...)
{
poco_unexpected();
}
}
void Preparator::freeMemory() const void Preparator::freeMemory() const

View File

@ -69,6 +69,8 @@ SessionImpl::SessionImpl(const std::string& connect,
SessionImpl::~SessionImpl() SessionImpl::~SessionImpl()
{
try
{ {
if (isTransaction() && !getFeature("autoCommit")) if (isTransaction() && !getFeature("autoCommit"))
{ {
@ -76,8 +78,12 @@ SessionImpl::~SessionImpl()
catch (...) { } catch (...) { }
} }
try { close(); } close();
catch (...) { } }
catch (...)
{
poco_unexpected();
}
} }

View File

@ -103,9 +103,16 @@ struct SQLite_API SQLiteConnectorRegistrator
~SQLiteConnectorRegistrator() ~SQLiteConnectorRegistrator()
/// Calls Poco::Data::SQLite::unregisterConnector(); /// Calls Poco::Data::SQLite::unregisterConnector();
{
try
{ {
Poco::Data::SQLite::Connector::unregisterConnector(); Poco::Data::SQLite::Connector::unregisterConnector();
} }
catch (...)
{
poco_unexpected();
}
}
}; };

View File

@ -44,9 +44,16 @@ Notifier::Notifier(const Session& session, const Any& value, EnabledEventType en
Notifier::~Notifier() Notifier::~Notifier()
{
try
{ {
disableAll(); disableAll();
} }
catch (...)
{
poco_unexpected();
}
}
bool Notifier::enableUpdate() bool Notifier::enableUpdate()

View File

@ -51,9 +51,16 @@ SQLiteStatementImpl::SQLiteStatementImpl(Poco::Data::SessionImpl& rSession, sqli
SQLiteStatementImpl::~SQLiteStatementImpl() SQLiteStatementImpl::~SQLiteStatementImpl()
{
try
{ {
clear(); clear();
} }
catch (...)
{
poco_unexpected();
}
}
void SQLiteStatementImpl::compileImpl() void SQLiteStatementImpl::compileImpl()

View File

@ -56,9 +56,16 @@ SessionImpl::SessionImpl(const std::string& fileName, std::size_t loginTimeout):
SessionImpl::~SessionImpl() SessionImpl::~SessionImpl()
{
try
{ {
close(); close();
} }
catch (...)
{
poco_unexpected();
}
}
Poco::Data::StatementImpl* SessionImpl::createStatementImpl() Poco::Data::StatementImpl* SessionImpl::createStatementImpl()