summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/ACM.cpp13
-rw-r--r--cpp/src/Ice/ConnectionI.cpp8
-rw-r--r--cpp/test/Ice/acm/AllTests.cpp17
3 files changed, 35 insertions, 3 deletions
diff --git a/cpp/src/Ice/ACM.cpp b/cpp/src/Ice/ACM.cpp
index b8e9878309a..cc20ccc070d 100644
--- a/cpp/src/Ice/ACM.cpp
+++ b/cpp/src/Ice/ACM.cpp
@@ -45,8 +45,17 @@ IceInternal::ACMConfig::ACMConfig(const Ice::PropertiesPtr& p,
timeoutProperty = prefix + ".Timeout";
};
- this->timeout = IceUtil::Time::seconds(p->getPropertyAsIntWithDefault(timeoutProperty,
- static_cast<int>(dflt.timeout.toSeconds())));
+ int timeout = p->getPropertyAsIntWithDefault(timeoutProperty, static_cast<int>(dflt.timeout.toSeconds()));
+ if(timeout >= 0)
+ {
+ this->timeout = IceUtil::Time::seconds(timeout);
+ }
+ else
+ {
+ l->warning("invalid value for property `" + timeoutProperty + "', default value will be used instead");
+ this->timeout = dflt.timeout;
+ }
+
int hb = p->getPropertyAsIntWithDefault(prefix + ".Heartbeat", static_cast<int>(dflt.heartbeat));
if(hb >= static_cast<int>(ICE_ENUM(ACMHeartbeat, HeartbeatOff)) &&
hb <= static_cast<int>(ICE_ENUM(ACMHeartbeat, HeartbeatAlways)))
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index d584d6ccd44..1f3bb85464c 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -1147,6 +1147,14 @@ Ice::ConnectionI::setACM(const IceUtil::Optional<int>& timeout,
const IceUtil::Optional<Ice::ACMHeartbeat>& heartbeat)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(timeout && *timeout < 0)
+ {
+#ifdef ICE_CPP11_MAPPING
+ throw invalid_argument("invalid negative ACM timeout value");
+#else
+ throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "invalid negative ACM timeout value");
+#endif
+ }
if(!_monitor || _state >= StateClosed)
{
return;
diff --git a/cpp/test/Ice/acm/AllTests.cpp b/cpp/test/Ice/acm/AllTests.cpp
index d362b3b6bc6..94b8c0da84d 100644
--- a/cpp/test/Ice/acm/AllTests.cpp
+++ b/cpp/test/Ice/acm/AllTests.cpp
@@ -314,7 +314,7 @@ public:
proxy->sleep(4);
Lock sync(*this);
- test(_heartbeat >= 6);
+ test(_heartbeat >= 4);
}
};
@@ -618,6 +618,21 @@ public:
{
Ice::ConnectionPtr con = proxy->ice_getConnection();
+ try
+ {
+ con->setACM(-19, IceUtil::None, IceUtil::None);
+ test(false);
+ }
+#ifndef ICE_CPP11_MAPPING
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ }
+#else
+ catch(const invalid_argument&)
+ {
+ }
+#endif
+
Ice::ACM acm;
acm = con->getACM();
test(acm.timeout == 15);