Code Monkey home page Code Monkey logo

Comments (7)

dsrees avatar dsrees commented on July 16, 2024

Is payload an optional value from Phoenix? I was under the impression that it would return an empty payload if none was specified

from javaphoenixclient.

lukasz-kalnik-gcx avatar lukasz-kalnik-gcx commented on July 16, 2024

I don't know how it's specified, but our app is crashing with an NPE inside on(event: String, callback: (Message) -> Unit) when trying in the callback to perform the message.payload.isNotEmpty() check, saying that the Map instance is null.

from javaphoenixclient.

dsrees avatar dsrees commented on July 16, 2024

I would say you have a bug in your phoenix app. There should always be a payload at least in the form of

"payload":{"status":"ok", ...}

A message without a payload doesn't have much value to it. I will try to verify this behavior on phoenix but until then, im hesitant to make any change

from javaphoenixclient.

lukasz-kalnik-gcx avatar lukasz-kalnik-gcx commented on July 16, 2024

A message without payload still has a value. There are sometimes events which don't carry any information, apart from that the event happened (e.g. scan finished or something like this).

Also I don't insist on changing the API to make payload nullable. I know this would break the code of existing library users.
I think the fix should rather be making sure that the non-nullable contract of this field is not broken by Gson.

from javaphoenixclient.

dsrees avatar dsrees commented on July 16, 2024

I might be missing something, but this test case passes while the json is missing a payload

@Test
  internal fun `parses from Gson if missing payload`() {
    val json = """
      {"topic":"phoenix","ref":"82","event":"phx_reply"}
    """
    val message = Defaults.gson.fromJson(json, Message::class.java)
    assertThat(message.payload).isNotNull()
  }

from javaphoenixclient.

lukasz-kalnik-gcx avatar lukasz-kalnik-gcx commented on July 16, 2024

Yes, indeed, the test passes. I don't know why at runtime on an Android device it then still returns null.
Never mind, we have found a workaround in our app. So you can close the issue.

Thanks for your support!

from javaphoenixclient.

dsrees avatar dsrees commented on July 16, 2024

Of course. Thanks for reaching out!

from javaphoenixclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.