Skip to content

Commit

Permalink
No need to explicitly deregister handler from registry
Browse files Browse the repository at this point in the history
The handler's logic already defers the deregister operation
when it stops processing the stream.

FAB-17047

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
  • Loading branch information
wlahti authored and sykesm committed Jan 27, 2020
1 parent 0f18fc9 commit 5c6bdda
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
5 changes: 0 additions & 5 deletions core/chaincode/runtime_launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,5 @@ func (r *RuntimeLauncher) Stop(ccid string) error {
return errors.WithMessagef(err, "failed to stop chaincode %s", ccid)
}

err = r.Registry.Deregister(ccid)
if err != nil {
return errors.WithMessagef(err, "failed to deregister chaincode %s", ccid)
}

return nil
}
16 changes: 0 additions & 16 deletions core/chaincode/runtime_launcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,6 @@ var _ = Describe("RuntimeLauncher", func() {
Expect(fakeRuntime.StopCallCount()).To(Equal(1))
ccidArg := fakeRuntime.StopArgsForCall(0)
Expect(ccidArg).To(Equal("chaincode-name:chaincode-version"))

Expect(fakeRegistry.DeregisterCallCount()).To(Equal(1))
ccidArg = fakeRegistry.DeregisterArgsForCall(0)
Expect(ccidArg).To(Equal("chaincode-name:chaincode-version"))
})

Context("when stopping the runtime fails while stopping", func() {
Expand All @@ -477,18 +473,6 @@ var _ = Describe("RuntimeLauncher", func() {
It("preserves the initial error", func() {
err := runtimeLauncher.Stop("chaincode-name:chaincode-version")
Expect(err).To(MatchError("failed to stop chaincode chaincode-name:chaincode-version: liver-mush"))
Expect(fakeRegistry.DeregisterCallCount()).To(Equal(0))
})
})

Context("when deregistering fails while stopping", func() {
BeforeEach(func() {
fakeRegistry.DeregisterReturns(errors.New("pickled-okra"))
})

It("preserves the initial error", func() {
err := runtimeLauncher.Stop("chaincode-name:chaincode-version")
Expect(err).To(MatchError("failed to deregister chaincode chaincode-name:chaincode-version: pickled-okra"))
})
})
})

0 comments on commit 5c6bdda

Please sign in to comment.