Skip to content
Permalink
Browse files
8263138: Initialization of sun.font.SunFontManager.platformFontMap is…
… not thread safe

Reviewed-by: aivanov, kizune, serb
  • Loading branch information
turbanoff authored and mrserb committed Mar 20, 2021
1 parent 5b8233b commit ab66d6991d83a525e32540261bf9d4dcf116c9b1
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/java.desktop/share/classes/sun/font/SunFontManager.java
@@ -1433,9 +1433,10 @@ private void resolveFontFiles(HashSet<String> unmappedFiles,
public String boldFileName;
public String italicFileName;
public String boldItalicFileName;
boolean failed;
}

static HashMap<String, FamilyDescription> platformFontMap;
static volatile HashMap<String, FamilyDescription> platformFontMap;

/**
* default implementation does nothing.
@@ -1445,8 +1446,10 @@ private void resolveFontFiles(HashSet<String> unmappedFiles,
}

Font2D findFontFromPlatformMap(String lcName, int style) {
HashMap<String, FamilyDescription> platformFontMap = SunFontManager.platformFontMap;
if (platformFontMap == null) {
platformFontMap = populateHardcodedFileNameMap();
SunFontManager.platformFontMap = platformFontMap;
}

if (platformFontMap == null || platformFontMap.size() == 0) {
@@ -1460,7 +1463,7 @@ Font2D findFontFromPlatformMap(String lcName, int style) {
}

FamilyDescription fd = platformFontMap.get(firstWord);
if (fd == null) {
if (fd == null || fd.failed) {
return null;
}
/* Once we've established that its at least the first word,
@@ -1527,7 +1530,7 @@ Font2D findFontFromPlatformMap(String lcName, int style) {
if (FontUtilities.isLogging()) {
FontUtilities.logInfo("Hardcoded file missing looking for " + lcName);
}
platformFontMap.remove(firstWord);
fd.failed = true;
return null;
}

@@ -1554,7 +1557,7 @@ public Boolean run() {
if (FontUtilities.isLogging()) {
FontUtilities.logInfo("Hardcoded file missing looking for " + lcName);
}
platformFontMap.remove(firstWord);
fd.failed = true;
return null;
}

1 comment on commit ab66d69

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on ab66d69 Mar 20, 2021

Please sign in to comment.