private static void checkMultiplicity(HandlerContext ctx) {
        Handler handler = ctx.handler();
        if (handler instanceof HandlerAdapter) {
            HandlerAdapter h = (HandlerAdapter) handler;
            if (!h.isSharable() && h.added) {
                throw new PipelineException(
                        h.getClass().getName() +
                                " is not a @Sharable handler, so can't be added or removed multiple times.");
            }
            h.added = true;
        }
    }
Most of the code references the pipeline design of
<a href="https://github.com/netty/netty">Netty</a>.

@author jiachun.fjc
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/util/pipeline/DefaultPipeline.java