Error when parsing `NetworkInfo` when `avg_out_degree` is `NaN`
Closed this issue ยท 5 comments
Subject of the issue
Parse error of NetworkInfo
when avg_out_degree
is NaN
.
Your environment
- version of lightningj:
0.15.3-Beta
- version of lnd:
0.15.3-beta
- version and vendor of JDK:
openjdk 11.0.16.1 2022-08-12
- your operationg systems:
Linux x1 5.19.16
Steps to reproduce
Install a fresh lnd server on regtest and execute getnetworkinfo
bash-5.1# lncli --network=regtest getnetworkinfo
{
"graph_diameter": 0,
"avg_out_degree": "NaN",
"max_out_degree": 0,
"num_nodes": 0,
"num_channels": 0,
"total_network_capacity": "0",
"avg_channel_size": 0,
"min_channel_size": "0",
"max_channel_size": "0",
"median_channel_size_sat": "0",
"num_zombie_chans": "0"
}
Expected behaviour
Should parse message successfully.
Actual behaviour
Throws exception:
Error converting Message to JSON: Character N is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
javax.json.JsonException: Error converting Message to JSON: Character N is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
at app//org.lightningj.lnd.wrapper.Message.toJson(Message.java:79)
at app//org.lightningj.lnd.wrapper.Message.toJsonAsString(Message.java:90)
at app//org.lightningj.lnd.wrapper.Message.toString(Message.java:121)
at app//org.lightningj.lnd.wrapper.SynchronousAPI.processResponse(SynchronousAPI.java:79)
at app//org.lightningj.lnd.wrapper.SynchronousLndAPI.getNetworkInfo(SynchronousLndAPI.java:1591)
at app//org.lightningj.lnd.wrapper.SynchronousLndAPI.getNetworkInfo(SynchronousLndAPI.java:1575)
Ok I will test this a bit later, Maybe the JSON Parser library needs to be updated t support NaN. Didn't know that GRPC supported such values. Have to study this to see how we best solve this problem.
Seems like it. From the spec for "Floating-point literals":
floatLit = [...] | "inf" | "nan"
Hi again, I have created a snaphot with a fix using the code above. I tried it out against my LND but didn't manage to get any NaN values. Maybe you can verify if it is fixed
The snapshot is:
implementation 'org.lightningj:lightningj:0.15.3.1-Beta-SNAPSHOT'
If it works for you I can create a proper release with a fix in a weeks time. I'm away traveling and cannot look at this next week.
If it works for you I can create a proper release with a fix in a weeks time. I'm away traveling and cannot look at this next week.
There is no urgency involved at all - I think it is mainly a regtest issue. Thank you for the quick response ๐
However, I think comparison needs to be made with .equalsIgnoreCase
, as the value can surprisingly be NaN
(have not witnessed Inf
|inf
in the wild yet
Updated fix is merged into upcoming 0.15.5. Closing this issue