Skip to content

Commit

Permalink
Disallow setAdapter on server connections
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Dec 3, 2024
1 parent 71b8054 commit 4d2dcdc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cpp/src/Ice/ConnectionI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,11 @@ Ice::ConnectionI::connector() const
void
Ice::ConnectionI::setAdapter(const ObjectAdapterPtr& adapter)
{
if (!_connector) // server connection
{
throw std::logic_error{"setAdapter can only be called on a client connection"};
}

if (adapter)
{
// Go through the adapter to set the adapter on this connection
Expand Down
5 changes: 5 additions & 0 deletions csharp/src/Ice/ConnectionI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@ internal Connector connector()

public void setAdapter(ObjectAdapter adapter)
{
if (_connector is null) // server connection
{
throw new InvalidOperationException("setAdapter can only be called on a client connection");
}

if (adapter is not null)
{
// Go through the adapter to set the adapter and servant manager on this connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ public Connector connector() {

@Override
public void setAdapter(ObjectAdapter adapter) {
if (_connector == null) { // server connection
throw new UnsupportedOperationException(
"setAdapter can only be called on a client connection");
}

if (adapter != null) {
// Go through the adapter to set the adapter on this connection to ensure the
// object adapter is still active and to ensure proper locking order.
Expand Down

0 comments on commit 4d2dcdc

Please sign in to comment.