[HUDI-2219] Fix NPE of HoodieConfig (#3342)
This commit is contained in:
@@ -45,19 +45,21 @@ public class ReflectionUtils {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(ReflectionUtils.class);
|
||||
|
||||
private static Map<String, Class<?>> clazzCache = new HashMap<>();
|
||||
private static final Map<String, Class<?>> CLAZZ_CACHE = new HashMap<>();
|
||||
|
||||
public static Class<?> getClass(String clazzName) {
|
||||
if (!clazzCache.containsKey(clazzName)) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(clazzName, true,
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
clazzCache.put(clazzName, clazz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new HoodieException("Unable to load class", e);
|
||||
synchronized (CLAZZ_CACHE) {
|
||||
if (!CLAZZ_CACHE.containsKey(clazzName)) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(clazzName, true,
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
CLAZZ_CACHE.put(clazzName, clazz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new HoodieException("Unable to load class", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return clazzCache.get(clazzName);
|
||||
return CLAZZ_CACHE.get(clazzName);
|
||||
}
|
||||
|
||||
public static <T> T loadClass(String fqcn) {
|
||||
|
||||
Reference in New Issue
Block a user