The potential performance penalty should be trivial, and we should encourage use Optional in Dubbbo. I believe the static optimization from the compiler and the dynamic optimization from the JIT compiler will take care of it.
Thanks, -Ian. On Fri, Jan 18, 2019 at 8:05 PM Kun Song <[email protected]> wrote: > Hi community, > > We will support Java 8 since Dubbo 2.7 according to Huxing’s comments > here [1], one big improvement of Java 8 is `Optional`, which is introduced > primarily to avoid `null` and `NullPointerException`. > > `Optional` will make programs more readable and less bug prone, and > some projects such as Apache Pulsar do use `Optional` a lot. However heavy > use of `Optional` may produce many small objects and hence introduce some > performance costs, my question is should we encourage `Optional` in Dubbo? > > Looking forward to hearing from you. > > [1] > https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757 > < > https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757 > >
