Skip to content

Commit

Permalink
HEAD:(zeroc-ice/ice@765d81587a) Fix raising of RequestFailedException…
Browse files Browse the repository at this point in the history
… in Python (zeroc-ice/ice#2589)
  • Loading branch information
pepone authored and temp committed Jul 31, 2024
1 parent 8bd95eb commit 9ec7547
Show file tree
Hide file tree
Showing 1,485 changed files with 2,614 additions and 2,244 deletions.
12 changes: 6 additions & 6 deletions slice2cpp/cpp/src/IceGrid/Internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1585,11 +1585,11 @@ IceGrid::ReplicaSessionPrx::_iceI_setAdapterDirectProxy(const ::std::shared_ptr<
{
ex.ice_throw();
}
catch(const AdapterExistsException&)
catch(const AdapterNotExistException&)
{
throw;
}
catch(const AdapterNotExistException&)
catch(const AdapterExistsException&)
{
throw;
}
Expand Down Expand Up @@ -1700,11 +1700,11 @@ IceGrid::InternalRegistryPrx::_iceI_registerNode(const ::std::shared_ptr<::IceIn
{
ex.ice_throw();
}
catch(const NodeActiveException&)
catch(const PermissionDeniedException&)
{
throw;
}
catch(const PermissionDeniedException&)
catch(const NodeActiveException&)
{
throw;
}
Expand Down Expand Up @@ -1750,11 +1750,11 @@ IceGrid::InternalRegistryPrx::_iceI_registerReplica(const ::std::shared_ptr<::Ic
{
ex.ice_throw();
}
catch(const ReplicaActiveException&)
catch(const PermissionDeniedException&)
{
throw;
}
catch(const PermissionDeniedException&)
catch(const ReplicaActiveException&)
{
throw;
}
Expand Down
62 changes: 58 additions & 4 deletions slice2cpp/python/test/Ice/exceptions/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,37 @@ Test::ThrowerPrx::_iceI_throwMarshalException(const ::std::shared_ptr<::IceInter
});
}

void
Test::ThrowerPrx::throwRequestFailedException(::std::string_view iceP_type, const ::Ice::Identity& iceP_id, ::std::string_view iceP_facet, ::std::string_view iceP_operation, const ::Ice::Context& context) const
{
::IceInternal::makePromiseOutgoing<void>(true, this, &ThrowerPrx::_iceI_throwRequestFailedException, iceP_type, iceP_id, iceP_facet, iceP_operation, context).get();
}

::std::future<void>
Test::ThrowerPrx::throwRequestFailedExceptionAsync(::std::string_view iceP_type, const ::Ice::Identity& iceP_id, ::std::string_view iceP_facet, ::std::string_view iceP_operation, const ::Ice::Context& context) const
{
return ::IceInternal::makePromiseOutgoing<void>(false, this, &ThrowerPrx::_iceI_throwRequestFailedException, iceP_type, iceP_id, iceP_facet, iceP_operation, context);
}

::std::function<void()>
Test::ThrowerPrx::throwRequestFailedExceptionAsync(::std::string_view iceP_type, const ::Ice::Identity& iceP_id, ::std::string_view iceP_facet, ::std::string_view iceP_operation, ::std::function<void()> response, ::std::function<void(::std::exception_ptr)> ex, ::std::function<void(bool)> sent, const ::Ice::Context& context) const
{
return ::IceInternal::makeLambdaOutgoing<void>(::std::move(response), ::std::move(ex), ::std::move(sent), this, &Test::ThrowerPrx::_iceI_throwRequestFailedException, iceP_type, iceP_id, iceP_facet, iceP_operation, context);
}

void
Test::ThrowerPrx::_iceI_throwRequestFailedException(const ::std::shared_ptr<::IceInternal::OutgoingAsyncT<void>>& outAsync, ::std::string_view iceP_type, const ::Ice::Identity& iceP_id, ::std::string_view iceP_facet, ::std::string_view iceP_operation, const ::Ice::Context& context) const
{
static constexpr ::std::string_view operationName = "throwRequestFailedException";

outAsync->invoke(operationName, ::Ice::OperationMode::Normal, ::Ice::FormatType::DefaultFormat, context,
[&](::Ice::OutputStream* ostr)
{
ostr->writeAll(iceP_type, iceP_id, iceP_facet, iceP_operation);
},
nullptr);
}

const char*
Test::ThrowerPrx::ice_staticId() noexcept
{
Expand Down Expand Up @@ -1423,14 +1454,32 @@ Test::Thrower::_iceD_throwMarshalException(::Ice::IncomingRequest& request, ::st
}
/// \endcond

/// \cond INTERNAL
void
Test::Thrower::_iceD_throwRequestFailedException(::Ice::IncomingRequest& request, ::std::function<void(::Ice::OutgoingResponse)> sendResponse)
{
_iceCheckMode(::Ice::OperationMode::Normal, request.current().mode);
auto istr = &request.inputStream();
istr->startEncapsulation();
::std::string iceP_type;
::Ice::Identity iceP_id;
::std::string iceP_facet;
::std::string iceP_operation;
istr->readAll(iceP_type, iceP_id, iceP_facet, iceP_operation);
istr->endEncapsulation();
this->throwRequestFailedException(::std::move(iceP_type), ::std::move(iceP_id), ::std::move(iceP_facet), ::std::move(iceP_operation), request.current());
sendResponse(::Ice::makeEmptyOutgoingResponse(request.current()));
}
/// \endcond

/// \cond INTERNAL
void
Test::Thrower::dispatch(::Ice::IncomingRequest& request, ::std::function<void(::Ice::OutgoingResponse)> sendResponse)
{
static constexpr ::std::string_view allOperations[] = {"ice_id", "ice_ids", "ice_isA", "ice_ping", "shutdown", "supportsAssertException", "supportsUndeclaredExceptions", "throwAasA", "throwAfterException", "throwAfterResponse", "throwAorDasAorD", "throwAssertException", "throwBasA", "throwBasB", "throwCasA", "throwCasB", "throwCasC", "throwLocalException", "throwLocalExceptionIdempotent", "throwMarshalException", "throwMemoryLimitException", "throwModA", "throwNonIceException", "throwUndeclaredA", "throwUndeclaredB", "throwUndeclaredC"};
static constexpr ::std::string_view allOperations[] = {"ice_id", "ice_ids", "ice_isA", "ice_ping", "shutdown", "supportsAssertException", "supportsUndeclaredExceptions", "throwAasA", "throwAfterException", "throwAfterResponse", "throwAorDasAorD", "throwAssertException", "throwBasA", "throwBasB", "throwCasA", "throwCasB", "throwCasC", "throwLocalException", "throwLocalExceptionIdempotent", "throwMarshalException", "throwMemoryLimitException", "throwModA", "throwNonIceException", "throwRequestFailedException", "throwUndeclaredA", "throwUndeclaredB", "throwUndeclaredC"};

const ::Ice::Current& current = request.current();
::std::pair<const ::std::string_view*, const ::std::string_view*> r = ::std::equal_range(allOperations, allOperations + 26, current.operation);
::std::pair<const ::std::string_view*, const ::std::string_view*> r = ::std::equal_range(allOperations, allOperations + 27, current.operation);
if(r.first == r.second)
{
sendResponse(::Ice::makeOutgoingResponse(::std::make_exception_ptr(::Ice::OperationNotExistException(__FILE__, __LINE__)), current));
Expand Down Expand Up @@ -1556,15 +1605,20 @@ Test::Thrower::dispatch(::Ice::IncomingRequest& request, ::std::function<void(::
}
case 23:
{
_iceD_throwUndeclaredA(request, ::std::move(sendResponse));
_iceD_throwRequestFailedException(request, ::std::move(sendResponse));
break;
}
case 24:
{
_iceD_throwUndeclaredB(request, ::std::move(sendResponse));
_iceD_throwUndeclaredA(request, ::std::move(sendResponse));
break;
}
case 25:
{
_iceD_throwUndeclaredB(request, ::std::move(sendResponse));
break;
}
case 26:
{
_iceD_throwUndeclaredC(request, ::std::move(sendResponse));
break;
Expand Down
17 changes: 17 additions & 0 deletions slice2cpp/python/test/Ice/exceptions/Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <Ice/PushDisableWarnings.h>
#include <Ice/Ice.h>
#include <Ice/BuiltinSequences.h>
#include <Ice/Identity.h>

#ifndef ICE_IGNORE_VERSION
# if ICE_INT_VERSION != 30850
Expand Down Expand Up @@ -336,6 +337,17 @@ class ThrowerPrx : public ::Ice::Proxy<ThrowerPrx, ::Ice::ObjectPrx>
void _iceI_throwMarshalException(const ::std::shared_ptr<::IceInternal::OutgoingAsyncT<::std::tuple<::std::int32_t, ::std::int32_t>>>&, const ::Ice::Context&) const;
/// \endcond

void throwRequestFailedException(::std::string_view type, const ::Ice::Identity& id, ::std::string_view facet, ::std::string_view operation, const ::Ice::Context& context = ::Ice::noExplicitContext) const;

::std::future<void> throwRequestFailedExceptionAsync(::std::string_view type, const ::Ice::Identity& id, ::std::string_view facet, ::std::string_view operation, const ::Ice::Context& context = ::Ice::noExplicitContext) const;

::std::function<void()>
throwRequestFailedExceptionAsync(::std::string_view type, const ::Ice::Identity& id, ::std::string_view facet, ::std::string_view operation, ::std::function<void()> response, ::std::function<void(::std::exception_ptr)> ex = nullptr, ::std::function<void(bool)> sent = nullptr, const ::Ice::Context& context = ::Ice::noExplicitContext) const;

/// \cond INTERNAL
void _iceI_throwRequestFailedException(const ::std::shared_ptr<::IceInternal::OutgoingAsyncT<void>>&, ::std::string_view, const ::Ice::Identity&, ::std::string_view, ::std::string_view, const ::Ice::Context&) const;
/// \endcond

/**
* Obtains the Slice type ID of this interface.
* @return The fully-scoped type ID.
Expand Down Expand Up @@ -835,6 +847,11 @@ class Thrower : public virtual ::Ice::Object
void _iceD_throwMarshalException(::Ice::IncomingRequest&, ::std::function<void(::Ice::OutgoingResponse)>);
/// \endcond

virtual void throwRequestFailedException(::std::string type, ::Ice::Identity id, ::std::string facet, ::std::string operation, const ::Ice::Current& current) = 0;
/// \cond INTERNAL
void _iceD_throwRequestFailedException(::Ice::IncomingRequest&, ::std::function<void(::Ice::OutgoingResponse)>);
/// \endcond

/// \cond INTERNAL
void dispatch(::Ice::IncomingRequest&, ::std::function<void(::Ice::OutgoingResponse)>) override;
/// \endcond
Expand Down
12 changes: 6 additions & 6 deletions slice2cs/cpp/src/IceGrid/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6728,10 +6728,10 @@ public abstract class ServerDisp_ : Ice.ObjectImpl, Server

public abstract global::System.Threading.Tasks.Task setProcessAsync(global::Ice.ProcessPrx? proc, Ice.Current current);

public abstract long getOffsetFromEnd(string filename, int lines, Ice.Current current);

public abstract bool read(string filename, long pos, int size, out long newPos, out string[] lines, Ice.Current current);

public abstract long getOffsetFromEnd(string filename, int lines, Ice.Current current);

public override string ice_id(Ice.Current current) => ice_staticId();

public static new string ice_staticId() => "::IceGrid::Server";
Expand Down Expand Up @@ -6811,8 +6811,6 @@ public abstract class NodeDisp_ : Ice.ObjectImpl, Node

public abstract void shutdown(Ice.Current current);

public abstract long getOffsetFromEnd(string filename, int lines, Ice.Current current);

public abstract bool read(string filename, long pos, int size, out long newPos, out string[] lines, Ice.Current current);

public abstract void replicaInit(InternalRegistryPrx?[] replicas, Ice.Current current);
Expand All @@ -6821,6 +6819,8 @@ public abstract class NodeDisp_ : Ice.ObjectImpl, Node

public abstract void replicaRemoved(InternalRegistryPrx? replica, Ice.Current current);

public abstract long getOffsetFromEnd(string filename, int lines, Ice.Current current);

public override string ice_id(Ice.Current current) => ice_staticId();

public static new string ice_staticId() => "::IceGrid::Node";
Expand Down Expand Up @@ -7014,10 +7014,10 @@ public abstract class InternalRegistryDisp_ : Ice.ObjectImpl, InternalRegistry

public abstract void shutdown(Ice.Current current);

public abstract long getOffsetFromEnd(string filename, int lines, Ice.Current current);

public abstract bool read(string filename, long pos, int size, out long newPos, out string[] lines, Ice.Current current);

public abstract long getOffsetFromEnd(string filename, int lines, Ice.Current current);

public override string ice_id(Ice.Current current) => ice_staticId();

public static new string ice_staticId() => "::IceGrid::InternalRegistry";
Expand Down
8 changes: 4 additions & 4 deletions slice2cs/cpp/test/Ice/location/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,10 +1168,10 @@ public abstract class TestLocatorRegistryDisp_ : Ice.ObjectImpl, TestLocatorRegi

public abstract global::System.Threading.Tasks.Task setAdapterDirectProxyAsync(string id, global::Ice.ObjectPrx? proxy, Ice.Current current);

public abstract global::System.Threading.Tasks.Task setReplicatedAdapterDirectProxyAsync(string adapterId, string replicaGroupId, global::Ice.ObjectPrx? proxy, Ice.Current current);

public abstract global::System.Threading.Tasks.Task setServerProcessProxyAsync(string id, global::Ice.ProcessPrx? proxy, Ice.Current current);

public abstract global::System.Threading.Tasks.Task setReplicatedAdapterDirectProxyAsync(string adapterId, string replicaGroupId, global::Ice.ObjectPrx? proxy, Ice.Current current);

public override string ice_id(Ice.Current current) => ice_staticId();

public static new string ice_staticId() => "::Test::TestLocatorRegistry";
Expand All @@ -1197,12 +1197,12 @@ public abstract class TestLocatorDisp_ : Ice.ObjectImpl, TestLocator
{
public abstract int getRequestCount(Ice.Current current);

public abstract global::Ice.LocatorRegistryPrx? getRegistry(Ice.Current current);

public abstract global::System.Threading.Tasks.Task<global::Ice.ObjectPrx?> findObjectByIdAsync(global::Ice.Identity id, Ice.Current current);

public abstract global::System.Threading.Tasks.Task<global::Ice.ObjectPrx?> findAdapterByIdAsync(string id, Ice.Current current);

public abstract global::Ice.LocatorRegistryPrx? getRegistry(Ice.Current current);

public override string ice_id(Ice.Current current) => ice_staticId();

public static new string ice_staticId() => "::Test::TestLocator";
Expand Down
Loading

0 comments on commit 9ec7547

Please sign in to comment.