diff options
author | Thomas <> | 2024-04-04 08:21:05 +0200 |
---|---|---|
committer | Thomas <> | 2024-04-04 08:21:05 +0200 |
commit | 7ef6302c42bbc603e14c062f8f9a1f26a2fc29e8 (patch) | |
tree | ce8adfff23700b3a38272195b0f5e19d906f454d | |
parent | 9b44bb28597a8a05f70e6fdfa9ccb559b6f643d2 (diff) | |
download | EAAF-Components-7ef6302c42bbc603e14c062f8f9a1f26a2fc29e8.tar.gz EAAF-Components-7ef6302c42bbc603e14c062f8f9a1f26a2fc29e8.tar.bz2 EAAF-Components-7ef6302c42bbc603e14c062f8f9a1f26a2fc29e8.zip |
fix(jackson): reflection based Jackson modul loader
Reason: Construct modul classes was wrong implemented before
-rw-r--r-- | eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DefaultJsonMapper.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DefaultJsonMapper.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DefaultJsonMapper.java index 92bf94d4..b6586bff 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DefaultJsonMapper.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DefaultJsonMapper.java @@ -1,8 +1,8 @@ package at.gv.egiz.eaaf.core.impl.utils; import java.io.IOException; +import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.PropertyAccessor; @@ -135,11 +135,12 @@ public final class DefaultJsonMapper { private static Module getModuleInstance(Class<?> clazz, String constructorName) { try { - final Method constructor = clazz.getMethod(constructorName, new Class[] {}); + + final Constructor<?> constructor = clazz.getConstructor(new Class[] {}); if (constructor != null) { log.trace("Found method: {} for class:{}. Creating instanze .... ", constructorName, clazz.getName()); - final Object rawModule = constructor.invoke(clazz); + final Object rawModule = constructor.newInstance(null); return rawModule instanceof Module ? (Module) rawModule : null; } else { @@ -148,8 +149,8 @@ public final class DefaultJsonMapper { } } catch (NoSuchMethodException | SecurityException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException e) { - log.debug("Can not create instanze of Jackson module: {}. Reason: {}", clazz.getName(), e.getMessage()); + | IllegalArgumentException | InvocationTargetException | InstantiationException e) { + log.info("Can not create instanze of Jackson module: {}. Reason: {}", clazz.getName(), e.getMessage()); log.trace("Detailed error", e); } |