Skip to content

Commit

Permalink
[MRESOLVER-373] Make GavNameResolver to distinguish names better (s4u…
Browse files Browse the repository at this point in the history
…#303)

This class currently gives away same names for artifact and metadata locks, that causes MRESOLVER-373 where artifact and metadata resolver together attempt illegal "lock upgrade", as both operate on same named lock.

This is wrong, as all other name mappers distinguish among them, also in case of snapshots, there are cases when shared lock is enough for artifact but metadata MAY need refresh, hence exclusive.

Important note: changing "naming" implies, that Maven carrying resolver with this change will be UNABLE to properly "share" local repository with older Mavens (so if this gets into Maven 3.9.3, it will properly share local repository other Maven 3.9.3+ instances, but not with 3.9.2, 3.9.1 or 3.9.0!)

---

https://issues.apache.org/jira/browse/MRESOLVER-373
  • Loading branch information
cstamas authored Jun 20, 2023
1 parent 1acec9b commit 4fb1cf9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ public static NameMapper gav() {
}

public static NameMapper fileGav() {
return new GAVNameMapper(true, "", ".lock", "", ".lock", "~");
return new GAVNameMapper(true, "artifact~", ".lock", "metadata~", ".lock", "~");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void singleArtifact() {
Collection<String> names = mapper.nameLocks(session, singletonList(artifact), null);

assertThat(names, hasSize(1));
assertThat(names.iterator().next(), equalTo("group~artifact~1.0.lock"));
assertThat(names.iterator().next(), equalTo("artifact~group~artifact~1.0.lock"));
}

@Test
Expand All @@ -69,7 +69,7 @@ public void singleMetadata() {
Collection<String> names = mapper.nameLocks(session, null, singletonList(metadata));

assertThat(names, hasSize(1));
assertThat(names.iterator().next(), equalTo("group~artifact.lock"));
assertThat(names.iterator().next(), equalTo("metadata~group~artifact.lock"));
}

@Test
Expand All @@ -83,7 +83,7 @@ public void oneAndOne() {
Iterator<String> namesIterator = names.iterator();

// they are sorted as well
assertThat(namesIterator.next(), equalTo("agroup~artifact~1.0.lock"));
assertThat(namesIterator.next(), equalTo("bgroup~artifact.lock"));
assertThat(namesIterator.next(), equalTo("artifact~agroup~artifact~1.0.lock"));
assertThat(namesIterator.next(), equalTo("metadata~bgroup~artifact.lock"));
}
}

0 comments on commit 4fb1cf9

Please sign in to comment.