Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning null in a function provided to telemetry.addData causes NPE #566

Open
TheGlitch76 opened this issue Jan 18, 2023 · 1 comment
Open

Comments

@TheGlitch76
Copy link

Calling telemetry.addData("foo", () -> null); in an OpMode will cause a NullPointerException at org.firstinspires.ftc.robotcore.internal.opmode.TelemetryImpl$Value.compose(TelemtryImpl.java:134) when telemetry is being updated.

The decompiled code doesn't make the reason immediately obvious.

@RadiGamer
Copy link
Member

When you call telemetry.addData("foo", () -> null);, you are adding a data point to the telemetry with the name "foo" and a value supplier that returns null. This means that when the telemetry tries to update and compose the data to be sent to the driver station, it will try to call the compose() method on the value supplier, which will throw a NullPointerException because the value supplier is returning null.

To avoid this error, you should make sure that the value supplier returns a non-null value or remove the call to telemetry.addData("foo", () -> null); if you do not actually need to add data with a null value to the telemetry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants