erocs/JukeAlert — pull request #32 by pruby (2013-05-21 23:36:30+00:00)
Title: Race condition in snitch records

There's a race condition waiting to happen around prepared statements and runTaskAsynchronously. The parameters are set, then an async task is scheduled to use them. If any of these functions is called again before the task runs, the first execution won't happen and the second will happen twice.

This makes the parameters final so that they can be used inside the Runnable, then sets the parameters right before calling the statement.

The second commit adds synchronized() locks around the statements. This is in case runTaskAsynchronously schedules two threads to run the same statement at once. It will make them go one at a time since the variable values are stored inside the statement and mustn't be mixed and matched.