Skip to content

Make MetaTableSchemaCache thread-safe #5956

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -15,9 +15,9 @@

package software.amazon.awssdk.enhanced.dynamodb.internal.mapper;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import software.amazon.awssdk.annotations.SdkInternalApi;

/**
@@ -27,7 +27,7 @@
@SdkInternalApi
@SuppressWarnings("unchecked")
public class MetaTableSchemaCache {
private final Map<Class<?>, MetaTableSchema<?>> cacheMap = new HashMap<>();
private final Map<Class<?>, MetaTableSchema<?>> cacheMap = new ConcurrentHashMap<>();

public <T> MetaTableSchema<T> getOrCreate(Class<T> mappedClass) {
return (MetaTableSchema<T>) cacheMap().computeIfAbsent(