goxr3plus / goxr3plus/java-stream-player

What to do if null?

Open
#36 1 comment 2 reactions 0 assignees View on GitHub
improvement question
Dominant language
Java
Stars
158
Forks
36
PR merge metrics
No merged PRs in 30d

Description

https://github.com/goxr3plus/java-stream-player/blob/4991e4acc52041ca1529404d176c57b4171eba94/src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java#L523

Why is this test for nullity there?

If sourceDataLine is null, the whole method openLine() does nothing, silently. Isn't that an error condition? Isn't it better to let a NullPointerException happen, and fix the bug so that it doesn't happen again?

I think it would be a good idea to make a wrapper class on SourceDataLine, where you are guaranteed that the sourceDataLine is not null. Then you don't need this kind of tests.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.