[
https://issues.apache.org/jira/browse/MESOS-6496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15634058#comment-15634058
]
Benjamin Bannier commented on MESOS-6496:
-----------------------------------------
Currently a number of tests use raw pointers to objects of mock classes and
construct {{Shared}}/{{Owned}} to inject, e.g.,
{code}
MockProvisioner* provisioner = new MockProvisioner();
// ...
EXPECT_CALL(*provisioner, destroy(_))
.WillOnce(Return(true));
// ...
MesosContainerizerProcess* process = new MesosContainerizerProcess(
// ...
Shared<Provisioner>(provisioner),
// ...);
{code}
(see e.g., https://reviews.apache.org/r/53387/#comment224436,
https://reviews.apache.org/r/53387/#comment224429,
https://reviews.apache.org/r/53387/#comment224430, or probably many other
instances in the code base). This code can leak if test expectations fail
before {{provisioner}} is wrapped into a smart ptr.
What we would really like to do here is to construct a managed ptr,
{{Shared<MockProvisioner> provisioner(new MockProvisioner())}} , access the
mocked functions with {{EXPECT_CALL}} which expected a mock class, and then
implicitly convert to a {{Shared<Provisioner>}} when injecting into the
{{MesosContainerizerProcess}} ctr.
> Support construction of Shared<Base> and Owned<Base> from managed Derived*
> --------------------------------------------------------------------------
>
> Key: MESOS-6496
> URL: https://issues.apache.org/jira/browse/MESOS-6496
> Project: Mesos
> Issue Type: Bug
> Components: libprocess
> Reporter: Neil Conway
> Assignee: Neil Conway
> Labels: mesosphere, tech-debt
>
> It should be possible to pass a {{Shared<Derived>}} value to an object that
> takes a parameter of type {{Shared<Base>}}. Similarly for {{Owned}}. In
> general, {{Shared<T2>}} should be implicitly convertable to {{Shared<T1>}}
> iff {{T2*}} is implicitly convertable to {{T1*}}. In C++11, this works
> because they define the appropriate conversion constructor.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)