Author: brane
Date: Fri Jul 12 15:31:17 2013
New Revision: 1502589
URL: http://svn.apache.org/r1502589
Log:
Use the new APR pool wrapper in the C++HL exception handler implementation.
* subversion/bindings/cxxhl/src/exception.cpp: Include aprwrap.hpp.
(handle_one_error): Replace apr_pool_t with APR::Pool reference.
(Error::compile_messages): Use an APR::Pool iteration pool and remove
the try-catch block, letting RAII do its thing. And remember to clear
the iterpool on each iteration.
* subversion/bindings/cxxhl/tests/test_exception.cpp:
Temporarily rewrap the test driver into a dummy Gtest testcase, so
that we actually exercise the exception handler in the tests again.
Modified:
subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp
subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp
Modified: subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp?rev=1502589&r1=1502588&r2=1502589&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp (original)
+++ subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp Fri Jul 12
15:31:17 2013
@@ -28,6 +28,7 @@
#include <sstream>
#include "svncxxhl/exception.hpp"
+#include "aprwrap.hpp"
#include "svn_error.h"
#include "svn_utf.h"
@@ -251,13 +252,13 @@ void Error::throw_svn_error(svn_error_t*
namespace {
void handle_one_error(Error::MessageList& ml, bool show_traces,
int error_code, detail::ErrorDescription* descr,
- apr_pool_t* pool)
+ const APR::Pool& pool)
{
if (show_traces && descr->file())
{
const char* file_utf8 = NULL;
svn_error_t* err =
- svn_utf_cstring_to_utf8(&file_utf8, descr->file(), pool);
+ svn_utf_cstring_to_utf8(&file_utf8, descr->file(), pool.get());
if (err)
{
svn_error_clear(err);
@@ -302,7 +303,7 @@ void handle_one_error(Error::MessageList
svn_error_t* err = svn_utf_cstring_to_utf8(
&description,
apr_strerror(error_code, errorbuf, sizeof(errorbuf)),
- pool);
+ pool.get());
if (err)
{
svn_error_clear(err);
@@ -333,33 +334,23 @@ Error::MessageList Error::compile_messag
std::vector<int> empties;
empties.reserve(max_length);
- apr_pool_t* pool = NULL;
- apr_pool_create(&pool, NULL);
- try
+ APR::Pool iterpool;
+ for (const Error* err = this; err; err = err->m_nested.get())
{
- for (const Error* err = this; err; err = err->m_nested.get())
+ if (!err->m_description->what())
{
- if (!err->m_description->what())
- {
- // Non-specific messages are printed only once.
- std::vector<int>::iterator it = std::find(
- empties.begin(), empties.end(), err->m_errno);
- if (it != empties.end())
- continue;
- empties.push_back(err->m_errno);
- }
- handle_one_error(ml, show_traces,
- err->m_errno, err->m_description,
- pool);
+ // Non-specific messages are printed only once.
+ std::vector<int>::iterator it = std::find(
+ empties.begin(), empties.end(), err->m_errno);
+ if (it != empties.end())
+ continue;
+ empties.push_back(err->m_errno);
}
+ handle_one_error(ml, show_traces,
+ err->m_errno, err->m_description,
+ iterpool);
+ iterpool.clear();
}
- catch (...)
- {
- apr_pool_destroy(pool);
- throw;
- }
-
- apr_pool_destroy(pool);
return ml;
}
Modified: subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp?rev=1502589&r1=1502588&r2=1502589&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp
(original)
+++ subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp Fri Jul
12 15:31:17 2013
@@ -138,17 +138,13 @@ int test_error()
return false;
}
+#include "gmock/gmock.h"
-int disabled_main()
+TEST(Exceptions, DummyTest)
{
- apr_initialize();
-
const char *stat = (test_cancel() ? "OK" : "ERROR");
std::cerr << "test_cancel .... " << stat << std::endl;
stat = (test_error() ? "OK" : "ERROR");
std::cerr << "test_error ..... " << stat << std::endl;
-
- apr_terminate();
- return 0;
}