Skip to content

Commit

Permalink
Remove unnecessary synchronization in AbstractVersionDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejj0 authored and slawekjaranowski committed Jan 2, 2023
1 parent c8a29db commit 9a725f6
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,14 @@ public abstract class AbstractVersionDetails implements VersionDetails {
+ "[-.]?(\\d{0,2}[a-z]?|\\d{6}\\.\\d{4})|\\d{8}(?:\\.?\\d{6})?)$");

/**
* The current version. Guarded by {@link #currentVersionLock}.
* Current version of the dependency artifact.
*
* @since 1.0-beta-1
*/
private ArtifactVersion currentVersion = null;

protected boolean verboseDetail = true;

/**
* Not sure if we need to be thread safe, but there's no harm being careful, after all we could be invoked from an
* IDE.
*
* @since 1.0-beta-1
*/
private final Object currentVersionLock = new Object();

protected AbstractVersionDetails() {}

@Override
Expand Down Expand Up @@ -121,16 +113,12 @@ public final boolean isCurrentVersionDefined() {

@Override
public final ArtifactVersion getCurrentVersion() {
synchronized (currentVersionLock) {
return currentVersion;
}
return currentVersion;
}

@Override
public final void setCurrentVersion(ArtifactVersion currentVersion) {
synchronized (currentVersionLock) {
this.currentVersion = currentVersion;
}
this.currentVersion = currentVersion;
}

@Override
Expand Down

0 comments on commit 9a725f6

Please sign in to comment.