#11284·rocketmq

[Bug] MessageStoreFactory reports every plugin initialization failure as "class not found"

Author: chennaji9Created Sep 30, 2026Updated Sep 30, 2026

Description

store/src/main/java/org/apache/rocketmq/store/plugin/MessageStoreFactory.java reports the wrong failure cause when a message-store plugin fails to initialize:

java
try {
    Class<AbstractPluginMessageStore> clazz = (Class<AbstractPluginMessageStore>) Class.forName(pluginClass);
    Constructor<AbstractPluginMessageStore> construct = clazz.getConstructor(MessageStorePluginContext.class, MessageStore.class);
    AbstractPluginMessageStore pluginMessageStore = construct.newInstance(context, messageStore);
    messageStore = pluginMessageStore;
} catch (Throwable e) {
    throw new RuntimeException("Initialize plugin's class: " + pluginClass + " not found!", e);
}

Class.forName, getConstructor and newInstance all share the single catch (Throwable), and every failure is wrapped as "... not found!". When the plugin class EXISTS but its constructor throws (misconfigured store, NPE in plugin init, illegal constructor args), the top-level message still claims the class was not found. The underlying cause is only visible if someone inspects the chain, and the misleading message actively sends the operator looking for classpath problems instead of the real failure.

Expected behavior

The exception message should describe the actual failure phase rather than hardcoding "not found" — e.g. "Failed to initialize message store plugin: <class>" — while preserving the original cause.