summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Glacier2/SessionRouterI.cpp34
-rw-r--r--cpp/test/Glacier2/sessionControl/Client.cpp20
-rw-r--r--cpp/test/Glacier2/sessionControl/SessionI.cpp11
3 files changed, 54 insertions, 11 deletions
diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp
index c59aa7f44b5..1103cd90412 100644
--- a/cpp/src/Glacier2/SessionRouterI.cpp
+++ b/cpp/src/Glacier2/SessionRouterI.cpp
@@ -773,7 +773,7 @@ Glacier2::SessionRouterI::createSessionInternal(const string& userId, bool allow
if(_sessionTraceLevel >= 1)
{
Trace out(_logger, "Glacier2");
- out << "exception while verifying password\n" << ex;
+ out << "exception while verifying password:\n" << ex;
}
PermissionDeniedException exc;
@@ -819,8 +819,8 @@ Glacier2::SessionRouterI::createSessionInternal(const string& userId, bool allow
// responsible for creating the filters and we want them to be
// accessible during session creation.
//
- FilterManagerPtr filterManager = FilterManager::create(_clientAdapter->getCommunicator(), _adminAdapter, userId,
- allowAddUserMode);
+ FilterManagerPtr filterManager = FilterManager::create(_clientAdapter->getCommunicator(), _adminAdapter,
+ userId, allowAddUserMode);
//
// If we have a session manager configured, we create a
@@ -844,7 +844,7 @@ Glacier2::SessionRouterI::createSessionInternal(const string& userId, bool allow
router = new RouterI(_clientAdapter, _serverAdapter, _adminAdapter, current.con, userId,
session, controlId, filterManager);
}
- catch(const Exception&)
+ catch(const Exception& ex)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -880,12 +880,26 @@ Glacier2::SessionRouterI::createSessionInternal(const string& userId, bool allow
}
}
- //
- // We throw ConnectionLostException here rather than the exception that
- // was raised by the session creation as the client should not receive
- // that information.
- //
- throw ConnectionLostException(__FILE__, __LINE__, 0);
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const Glacier2::CannotCreateSessionException&)
+ {
+ throw;
+ }
+ catch(const Exception&)
+ {
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "exception while creating session with session manager:\n" << ex;
+ }
+
+ CannotCreateSessionException exc;
+ exc.reason = "internal server error";
+ throw exc;
+ }
}
{
diff --git a/cpp/test/Glacier2/sessionControl/Client.cpp b/cpp/test/Glacier2/sessionControl/Client.cpp
index 73d9586bd95..29ed9bf9b36 100644
--- a/cpp/test/Glacier2/sessionControl/Client.cpp
+++ b/cpp/test/Glacier2/sessionControl/Client.cpp
@@ -54,6 +54,7 @@ SessionControlClient::run(int argc, char* argv[])
cout << "creating session... " << flush;
Glacier2::SessionPrx sessionBase = router->createSession("userid", "abc123");
Test::SessionPrx session = Test::SessionPrx::uncheckedCast(sessionBase);
+ test(session);
cout << "ok" << endl;
cout << "testing destroy... " << flush;
@@ -75,6 +76,25 @@ SessionControlClient::run(int argc, char* argv[])
}
cout << "ok" << endl;
+ cout << "testing create exceptions... " << flush;
+ try
+ {
+ router->createSession("rejectme", "abc123");
+ test(false);
+ }
+ catch(const Glacier2::CannotCreateSessionException&)
+ {
+ }
+ try
+ {
+ router->createSession("localexception", "abc123");
+ test(false);
+ }
+ catch(const Glacier2::CannotCreateSessionException&)
+ {
+ }
+ cout << "ok" << endl;
+
cout << "testing shutdown... " << flush;
session = Test::SessionPrx::uncheckedCast(router->createSession("userid", "abc123"));
session->shutdown();
diff --git a/cpp/test/Glacier2/sessionControl/SessionI.cpp b/cpp/test/Glacier2/sessionControl/SessionI.cpp
index 46726024255..de0bff8fdc9 100644
--- a/cpp/test/Glacier2/sessionControl/SessionI.cpp
+++ b/cpp/test/Glacier2/sessionControl/SessionI.cpp
@@ -40,8 +40,17 @@ private:
};
Glacier2::SessionPrx
-SessionManagerI::create(const string&, const Glacier2::SessionControlPrx& sessionControl, const Ice::Current& current)
+SessionManagerI::create(const string& userId, const Glacier2::SessionControlPrx& sessionControl,
+ const Ice::Current& current)
{
+ if(userId == "rejectme")
+ {
+ throw Glacier2::CannotCreateSessionException("");
+ }
+ if(userId == "localexception")
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(new SessionI(sessionControl)));
}