Skip to content

Commit d98f41c

Browse files
committed
Better enforcement of disabled modules and cleaned up some static imports
1 parent 79d2b9e commit d98f41c

File tree

1 file changed

+5
-2
lines changed
  • modules/simple-java-mail/src/main/java/org/simplejavamail/internal/modules

1 file changed

+5
-2
lines changed

modules/simple-java-mail/src/main/java/org/simplejavamail/internal/modules/ModuleLoader.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public static SMIMEModule loadSmimeModule() {
6767
}
6868

6969
public static BatchModule loadBatchModule() {
70+
if (FORCED_DISABLED_MODULES.contains(BatchModule.class)) {
71+
throw new AssertionError("BatchModule forcefully disabled");
72+
}
7073
if (!LOADED_MODULES.containsKey(BatchModule.class)) {
7174
LOADED_MODULES.put(BatchModule.class, loadModule(
7275
BatchModule.class,
@@ -93,11 +96,11 @@ private static <T> T loadModule(Class moduleClass,String moduleName, String modu
9396
throw new IllegalAccessException("Module is focrfully disabled");
9497
}
9598
if (!MiscUtil.classAvailable(moduleImplClassName)) {
96-
throw new org.simplejavamail.internal.modules.ModuleLoaderException(format(org.simplejavamail.internal.modules.ModuleLoaderException.ERROR_MODULE_MISSING, moduleName, moduleHome));
99+
throw new ModuleLoaderException(format(ModuleLoaderException.ERROR_MODULE_MISSING, moduleName, moduleHome));
97100
}
98101
return (T) Class.forName(moduleImplClassName).newInstance();
99102
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
100-
throw new org.simplejavamail.internal.modules.ModuleLoaderException(format(org.simplejavamail.internal.modules.ModuleLoaderException.ERROR_LOADING_MODULE, moduleName), e);
103+
throw new ModuleLoaderException(format(ModuleLoaderException.ERROR_LOADING_MODULE, moduleName), e);
101104
}
102105
}
103106

0 commit comments

Comments
 (0)