How to avoid flow stopping in case of handler returns null?

我们两清 提交于 2019-12-11 14:29:49

问题


I have following configuration:

flow -> flow.handle(myHandler)
                .filter(p -> {
                    log.warn("FILTER IS INVOKED");
                    return p != null;
                }

In case if myHandler#handle returns null - filter is not invoked.

How could I achieve passing null value to the filter ?


回答1:


I came up with workaround: create wrapper over handler return type:

class Wrapper {
   Foo foo;
   ...
}

At this case I can do following:

flow -> flow.handle(myHandler)
                .filter(p -> {
                    log.warn("FILTER IS INVOKED");
                    return p.getFoo() != null;
                }


来源:https://stackoverflow.com/questions/59047347/how-to-avoid-flow-stopping-in-case-of-handler-returns-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!