Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow setAdapter on server connections #3221

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading