Il Mar 18 Mag 2021, 18:15 Matteo Merli <mme...@apache.org> ha scritto:

> I believe this is a by-product of the protobuf changes. Google
> Protobuf returns an empty string if you're trying to access an
> optional field with no default value associated with it. This can lead
> to subtle bugs..
>
> Users of `Message` API should always check `hasKey()` before trying to
> do `getKey()`. (A better API would have been to return an
> `Optional<String>`).
>
> In any case, I'd rather not change the behavior of this right now, but
> leave it in the same form as 2.7 and earlier versions.
>

I can send a fix, at least for the Key, leaving the new behaviour for other
properties.

Let's wait for other comments or proposals


Enrico




>
> --
> Matteo Merli
> <mme...@apache.org>
>
> On Tue, May 18, 2021 at 12:50 AM Enrico Olivelli <eolive...@gmail.com>
> wrote:
> >
> > Hello,
> > I have found this behaviour in the Java Client while switching from 2.7
> to 2.8.
> >
> > Short version of the story:
> > - on 2.7.2 a null key is received as an empty key
> > - on 2.8.0 a null key is received as a null key
> >
> > The behaviour of 2.8 is better, because it is what you expect.
> >
> > But if you migrate an application from 2.7.2 to 2.8 you can start to
> > see Nulls instead of empty strings and this will lead to unpredictable
> > behaviour and possibly NullPointerExceptions.
> >
> > We can accept the new behaviour but I would like to check if the
> > community is aware of this and this is acceptable.
> >
> > This is the issue, with a reproducer
> > https://github.com/apache/pulsar/issues/10625
> >
> > Enrico
>

Reply via email to