Skip to content

Commit 1c11610

Browse files
Backport "Fix #19524: Protect use of HeaderIdGenerator with synchronized." to LTS (#20978)
Backports #19884 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 26fb24a + b48eee3 commit 1c11610

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scaladoc/src/dotty/tools/scaladoc/tasty/comments/markdown/SectionRenderingExtension.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ object SectionRenderingExtension extends HtmlRenderer.HtmlRendererExtension:
3535
val idSuffix = repeatedIds.getOrElseUpdate((c, headerText), 0)
3636
val ifSuffixStr = if(idSuffix == 0) then "" else idSuffix.toString
3737
repeatedIds.update((c, headerText), idSuffix + 1)
38-
val id = idGenerator.getId(headerText + ifSuffixStr)
38+
39+
/* #19524 flexmark's `HeaderIdGenerator` does not appear to be thread-safe,
40+
* so we protect its usage with a full `synchronize`.
41+
*/
42+
val id = idGenerator.synchronized {
43+
idGenerator.getId(headerText + ifSuffixStr)
44+
}
45+
3946
val anchor = AnchorLink(s"#$id")
4047
val headerClass: String = header.getLevel match
4148
case 1 => "h500"

0 commit comments

Comments
 (0)