apache/dubbo · error · UnsupportedOperationException
No instance of 'FileCacheStoreFactory' for you!
Error message
No instance of 'FileCacheStoreFactory' for you!
What it means
Thrown from the private constructor of FileCacheStoreFactory, which is a utility class meant to be used only via its static getInstance methods. Instantiating it directly (including via reflection) is forbidden and immediately fails.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/cache/FileCacheStoreFactory.java:51
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static org.apache.dubbo.common.constants.CommonConstants.SystemProperty.USER_HOME;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_CACHE_PATH_INACCESSIBLE;
/**
* ClassLoader Level static share.
* Prevent FileCacheStore being operated in multi-application
*/
public final class FileCacheStoreFactory {
/**
* Forbids instantiation.
*/
private FileCacheStoreFactory() {
throw new UnsupportedOperationException("No instance of 'FileCacheStoreFactory' for you! ");
}
private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(FileCacheStoreFactory.class);
private static final ConcurrentMap<String, FileCacheStore> cacheMap = new ConcurrentHashMap<>();
private static final String SUFFIX = ".dubbo.cache";
private static final char ESCAPE_MARK = '%';
private static final Set<Character> LEGAL_CHARACTERS = Collections.unmodifiableSet(new HashSet<Character>() {
{
// - $ . _ 0-9 a-z A-Z
add('-');
add('$');
add('.');
add('_');
for (char c = '0'; c <= '9'; c++) {
add(c);
}View on GitHub (pinned to 3a3043227f)
Solutions
- Never instantiate FileCacheStoreFactory; always call FileCacheStoreFactory.getInstance(basePath, cacheName).
- If a DI framework tries to construct it, exclude it from component scanning or mark it as a static utility.
- For tests, mock the FileCacheStore returned by getInstance rather than the factory itself.
Example fix
// before FileCacheStoreFactory f = new FileCacheStoreFactory(); // throws // after FileCacheStore cache = FileCacheStoreFactory.getInstance(null, "meta");
Defensive patterns
Strategy: validation
Validate before calling
// Never instantiate the factory; always use the static accessor FileCacheStore cache = FileCacheStoreFactory.getInstance(basePath, cacheName);
Try / catch
try {
FileCacheStoreFactory.class.getDeclaredConstructor().setAccessible(true);
// ... instantiation attempt
} catch (UnsupportedOperationException | ReflectiveOperationException e) {
// factory cannot be instantiated; use getInstance instead
} Prevention
- Always call FileCacheStoreFactory.getInstance instead of constructing it.
- Exclude utility classes from DI component scanning.
- Mock the returned FileCacheStore in tests, not the factory.
When it happens
Trigger: Code calls new FileCacheStoreFactory() directly, or reflection (Constructor.newInstance) invokes the private constructor. The constructor is private and throws, so both normal and reflective instantiation fail.
Common situations: A framework (Spring, a test util, a serialization lib) tries to instantiate the class reflectively. A developer unfamiliar with the API attempts to new it up instead of calling getInstance.
Related errors
- No instance of 'ConfigurationUtils' for you!
- create bean instance failed, type=${className}
- Expect only one but found ${size} matched constructors for t
- None matched constructor was found for type: ${type}
- No instance of 'NetUtils' for you!
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/4154d8e191b0fa4b.
Report an issue: GitHub.