Skip to content

Commit

Permalink
AbstractWorkerThread: add missing synchronization
Browse files Browse the repository at this point in the history
When running the worker, a call to initWorker() is done to create the
GearmanNIOJobServerConnectionImpl which is synchronized. The server
connection is then added to the worker but that was not synchronized
causing spotbugs to complain:

Inconsistent synchronization of hudson.plugins.gearman.AbstractWorkerThread.conn;
locked 50% of time
  • Loading branch information
hashar committed Jan 17, 2022
1 parent c5c403c commit 0f984f1
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ public void run() {
while (running) {
try {
logger.info("---- Starting Worker "+ getName() +" ("+new Date().toString()+")");
worker.addServer(conn);
synchronized(this) {
worker.addServer(conn);
}
worker.setWorkerID(name);
worker.setJobUniqueIdRequired(true);
registerJobs();
Expand Down

0 comments on commit 0f984f1

Please sign in to comment.