question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SerializeNullable annotation not work

See original GitHub issue

protocol

public class GetUserIdByIdRes {
    private @SerializeNullable byte[] userId;

    public GetUserIdByIdRes(@Deserialize("userId") byte[] userId) {
        this.userId = userId;
    }

    @Serialize
    public byte[] getUserId() {
        return userId;
    }
}

exception

java.util.concurrent.ExecutionException: io.activej.rpc.protocol.RpcRemoteException: java.lang.NullPointerException
	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1928)
	at com.test.rookiedb.rpc.RookieClient.multiGet(RookieClient.java:150)
	at com.test.rookiedb.rpc.RookieClient.getUserIdById(RookieClient.java:168)
	at com.test.rookiedb.RookieDbEngine.getUserIdById(RookieDbEngine.java:190)
	at com.test.BaseEngine.read(BaseEngine.java:164)
	at com.test.DefaultEngine.read(DefaultEngine.java:116)
	at com.test.DefaultEngineTest$ReadTask.run(DefaultEngineTest.java:161)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
	at java.util.concurrent.FutureTask.run(FutureTask.java)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: io.activej.rpc.protocol.RpcRemoteException: java.lang.NullPointerException

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
KciNKhcommented, Sep 29, 2022

In your original example, the location of the annotations is not correct. There are two solutions: either without getter and with public userId

public class GetUserIdByIdRes {

    @Serialize
    public byte @SerializeNullable [] userId;
}

in this case annotaion @Deserialize not required

or with getter with all serialize annotaions and priavte userId

public class GetUserIdByIdRes {
    private byte[] userId;

    public GetUserIdByIdRes(@Deserialize("userId") byte[] userId) {
        this.userId = userId;
    }

    @Serialize
    public byte @SerializeNullable [] getUserId() {
        return userId;
    }
}
0reactions
xsankcommented, Sep 29, 2022

@KciNKh thanks for your help~

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to tell Jackson to ignore a field during serialization if its ...
Include.NON_EMPTY indicates that property is serialized if its value is not null and not empty. Include.NON_NULL indicates that property is serialized if its ......
Read more >
Ignore Null Fields with Jackson - Baeldung
This quick tutorial is going to cover how to set up Jackson to ignore null fields when serializing a java class.
Read more >
Jackson - How to ignore null fields - Mkyong.com
To ignore the null fields, put @JsonInclude on class level or field level. 2. @JsonInclude – Class Level. Staff.java. import com.fasterxml.
Read more >
OpenAPITools/jackson-databind-nullable - GitHub
This module provides a JsonNullable wrapper class and a Jackson module to serialize/deserialize it. The JsonNullable wrapper shall be used to wrap Java...
Read more >
Ignore Null Fields with Jackson in Java and Spring Boot
In this tutorial, learn how to ignore null fields when serializing POJOs with Jackson, in Java and Spring Boot.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found