Notifier: add null check (#1684)

This commit is contained in:
Oblarg
2019-07-15 21:20:11 -04:00
committed by Peter Johnson
parent 10731f3d6b
commit fe59d854d5

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -12,6 +12,8 @@ import java.util.concurrent.locks.ReentrantLock;
import edu.wpi.first.hal.NotifierJNI;
import static java.util.Objects.requireNonNull;
public class Notifier implements AutoCloseable {
// The thread waiting on the HAL alarm.
private Thread m_thread;
@@ -85,6 +87,8 @@ public class Notifier implements AutoCloseable {
* using StartSingle or StartPeriodic.
*/
public Notifier(Runnable run) {
requireNonNull(run);
m_handler = run;
m_notifier.set(NotifierJNI.initializeNotifier());