Merge pull request #5863 from paulward24/master

HashMap is not thread safe.  The existing synchronized(map) is too small, should be extended to cover the surrounding code.
This commit is contained in:
Oleg Agafonov 2019-06-30 18:47:31 +02:00 committed by GitHub
commit 8b0586fa03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,10 +112,11 @@ public class ArrowBuilder {
* Removes all arrows from the screen.
*/
public void removeAllArrows(UUID gameId) {
if (map.containsKey(gameId)) {
Map<Type, List<Arrow>> innerMap = map.get(gameId);
JPanel p = getArrowsPanel(gameId);
synchronized (map) {
synchronized (map) {
if (map.containsKey(gameId)) {
Map<Type, List<Arrow>> innerMap = map.get(gameId);
JPanel p = getArrowsPanel(gameId);
if (p != null && p.getComponentCount() > 0) {
p.removeAll();
p.revalidate();