3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00
Paper/patches/unapplied/server/0876-Fix-concurrenct-access-to-lookups-field-in-RegistryO.patch

29 Zeilen
1.8 KiB
Diff

2023-05-27 20:34:33 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 15 May 2023 00:20:59 -0700
Subject: [PATCH] Fix concurrenct access to lookups field in RegistryOps
The concurrent access occurs on the Netty IO threads when
serializing packets. Thus, it seems it was an oversight of
the implementator of this function as there are typically
more than one Netty IO thread.
Fixes https://github.com/PaperMC/Folia/issues/11
diff --git a/src/main/java/net/minecraft/resources/RegistryOps.java b/src/main/java/net/minecraft/resources/RegistryOps.java
2024-04-23 19:02:08 +02:00
index 0272fe45449785e8589b6e42fa454f2abfcc0476..dd8a6bd463e5c8fe69271663cb46b45b201ba59c 100644
2023-05-27 20:34:33 +02:00
--- a/src/main/java/net/minecraft/resources/RegistryOps.java
+++ b/src/main/java/net/minecraft/resources/RegistryOps.java
@@ -19,7 +19,10 @@ public class RegistryOps<T> extends DelegatingOps<T> {
2023-05-27 20:34:33 +02:00
private static RegistryOps.RegistryInfoLookup memoizeLookup(RegistryOps.RegistryInfoLookup registryInfoGetter) {
2023-05-27 20:34:33 +02:00
return new RegistryOps.RegistryInfoLookup() {
- private final Map<ResourceKey<? extends Registry<?>>, Optional<? extends RegistryOps.RegistryInfo<?>>> lookups = new HashMap<>();
+ // The concurrent access occurs on the Netty IO threads when serializing packets.
+ // Thus, it seems it was an oversight of the implementator of this function as there
+ // are typically more than one Netty IO thread.
2023-05-27 20:34:33 +02:00
+ private final Map<ResourceKey<? extends Registry<?>>, Optional<? extends RegistryOps.RegistryInfo<?>>> lookups = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - fix concurrent access to lookups field
@Override
public <T> Optional<RegistryOps.RegistryInfo<T>> lookup(ResourceKey<? extends Registry<? extends T>> registryRef) {