Skip to content

Commit

Permalink
Changed the fix of "Synchronization on a non-final field" in this cla…
Browse files Browse the repository at this point in the history
…ss to the cleaner solution now also used elsewhere.
  • Loading branch information
jrg committed Feb 6, 2018
1 parent ee468ff commit abaa5e4
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -63,8 +63,6 @@ public class Heritrix3JobMonitorThread implements Runnable {
/** A map from harvest job number to the running H3 job monitor for the given job */
public Map<Long, Heritrix3JobMonitor> runningJobMonitorMap = new TreeMap<Long, Heritrix3JobMonitor>();

private final Object runningJobMonitorMapSynchronizer = new Object();

public Map<Long, Heritrix3JobMonitor> filterJobMonitorMap = new TreeMap<Long, Heritrix3JobMonitor>();

public final Set<String> h3HostPortSet = new HashSet<String>();
Expand Down Expand Up @@ -125,7 +123,7 @@ public boolean accept(File dir, String name) {
Heritrix3JobMonitor jobmonitor;

Iterator<Long> jobidIter = runningJobs.iterator();
synchronized (runningJobMonitorMapSynchronizer) {
synchronized (this) {
filterJobMonitorMap.clear();

// For all running jobs..
Expand Down Expand Up @@ -229,15 +227,15 @@ public Set<Long> getRunningJobs() {

public Heritrix3JobMonitor getRunningH3Job(long jobId) {
Heritrix3JobMonitor h3Job;
synchronized (runningJobMonitorMapSynchronizer) {
synchronized (this) {
h3Job = runningJobMonitorMap.get(jobId);
}
return h3Job;
}

public List<Heritrix3JobMonitor> getRunningH3Jobs() {
List<Heritrix3JobMonitor> h3JobsList = new LinkedList<Heritrix3JobMonitor>();
synchronized (runningJobMonitorMapSynchronizer) {
synchronized (this) {
h3JobsList.addAll(runningJobMonitorMap.values());
}
return h3JobsList;
Expand Down

0 comments on commit abaa5e4

Please sign in to comment.