Skip to content

Commit

Permalink
fix BuildStamps.incBuildStamp(IProject)
Browse files Browse the repository at this point in the history
postIncrement an reassignment is a NOOP. Stamp was never increased!
  • Loading branch information
EcljpseB0T authored and jukzi committed Jul 10, 2023
1 parent 7dd409f commit 64ca662
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.pde.api.tools.internal.builder;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.eclipse.core.resources.IProject;

Expand All @@ -23,20 +23,16 @@
*/
public class BuildStamps {

private static Map<IProject, long[]> fStamps = new HashMap<>();
private static final Map<IProject, Long> fStamps = new ConcurrentHashMap<>();

/**
* Returns the current build time stamp for the given project.
*
* @param project project
* @return relative build time stamp
*/
public static synchronized long getBuildStamp(IProject project) {
long[] stamp = fStamps.get(project);
if (stamp != null) {
return stamp[0];
}
return 0L;
public static long getBuildStamp(IProject project) {
return fStamps.getOrDefault(project, 0L);
}

/**
Expand All @@ -45,12 +41,7 @@ public static synchronized long getBuildStamp(IProject project) {
*
* @param project project being built
*/
public static synchronized void incBuildStamp(IProject project) {
long[] stamp = fStamps.get(project);
if (stamp != null) {
stamp[0] = stamp[0]++;
} else {
fStamps.put(project, new long[] { 1L });
}
public static void incBuildStamp(IProject project) {
fStamps.compute(project, (p, v) -> v == null ? 1L : v + 1L);
}
}

0 comments on commit 64ca662

Please sign in to comment.