protostuff/protostuff

NPE from RuntimeEnv.loadClass

baobinghai opened this issue · 0 comments

NPE happens in my app.
pls see the code below:

method : io.protostuff.runtime.RuntimeEnv#loadClass

@SuppressWarnings("unchecked")
static <T> Class<T> loadClass(String className)
{
    try
    {
        return (Class<T>) Thread.currentThread().getContextClassLoader()
                .loadClass(className);
    }
    catch (ClassNotFoundException e)
    {
        try {
            return (Class<T>) Class.forName(className);
        } catch (ClassNotFoundException e1) {
            throw new RuntimeException(e);
        }
    }
}

when i use netty GlobalEventExecutor to support thread asynchronization, GlobalEventExecutor would setContextClassLoader((ClassLoader)null),

so Thread.currentThread().getContextClassLoader() is null ,it will lead to NPE.

beside ,i have see this issue :
#223

image
image