Skip to content

Commit 988f34e

Browse files
committed
Corrected NPE when recording events
1 parent 2ab4f40 commit 988f34e

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
strongback.version=1.2.0-Beta2
1+
strongback.version=1.2.0-Beta3
22
#
33
# The build will download a specific version of the WPILib given by the following URL
44
# and install it into the 'libs/wpilib' folder. To use a different version of WPILib,

strongback/src/org/strongback/Strongback.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,10 +1258,12 @@ public String toString() {
12581258
return true;
12591259
}
12601260

1261-
private CommandListener createCommandListener() {
1262-
if (recordCommands) {
1261+
private CommandListener createCommandListener(EventRecorder recorder, boolean recordCommands) {
1262+
if (recordCommands && recorder != null) {
12631263
return (command, state) -> {
1264-
eventRecorder.record(command.getClass().getName(), state.ordinal());
1264+
if (command != null) {
1265+
recorder.record(command.getClass().getName(), state.ordinal());
1266+
}
12651267
};
12661268
}
12671269
return null;
@@ -1287,26 +1289,35 @@ protected boolean doStart() {
12871289
try {
12881290
executorDelayCounter.set(0);
12891291

1292+
// Create the event recorder if needed ...
1293+
boolean listenToCommands = false;
1294+
if (eventWriter != null) {
1295+
eventRecorder = new AsyncEventRecorder(eventWriter, clock);
1296+
eventRecorder.execute(CLOCK.currentTimeInMillis());
1297+
listenToCommands = recordCommands;
1298+
}
1299+
12901300
// Create the scheduler that runs commands ...
1291-
scheduler = new Scheduler(logger, createCommandListener());
1301+
scheduler = new Scheduler(logger, createCommandListener(eventRecorder,listenToCommands));
1302+
scheduler.execute(CLOCK.currentTimeInMillis());
12921303
executables.register(scheduler, SCHEDULER_PRIORITY);
12931304

12941305
if (useSwitchReactor) {
12951306
// Register the switch reactor ...
12961307
executables.register(switchReactor, SWITCH_REACTOR_PRIORITY);
1308+
switchReactor.execute(CLOCK.currentTimeInMillis());
12971309
}
12981310

12991311
// Create the data recorder if needed ...
13001312

13011313
if (dataWriterFactorySupplier != null) {
13021314
dataRecorderDriver = new DataRecorderDriver(dataRecorderChannels, dataWriterFactorySupplier.get());
13031315
dataRecorderDriver.start();
1316+
dataRecorderDriver.execute(CLOCK.currentTimeInMillis());
13041317
executables.register(dataRecorderDriver, DATA_RECORDER_PRIORITY);
13051318
}
13061319

1307-
// Create the event recorder if needed ...
1308-
if (eventWriter != null) {
1309-
eventRecorder = new AsyncEventRecorder(eventWriter, clock);
1320+
if (eventRecorder != null) {
13101321
executables.register(eventRecorder, EVENT_RECORDER_PRIORITY);
13111322
}
13121323

0 commit comments

Comments
 (0)