Skip to content

Commit

Permalink
use proper object constructor call
Browse files Browse the repository at this point in the history
  • Loading branch information
cleaning-agent committed Aug 7, 2020
1 parent bd0e9e6 commit 56eb80d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/de/dm/prom/structuredlogging/MdcContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public final class MdcContext<SerializedType, MdcIdType extends MdcContextId<Ser
*/
public static <SerializedType, MdcIdType extends MdcContextId<SerializedType>> MdcContext<SerializedType, MdcIdType> of(Class<MdcIdType> type, SerializedType mdcValue) {
try {
MdcContextId<SerializedType> id = type.newInstance();
MdcContextId<SerializedType> id = type.getDeclaredConstructor().newInstance();
return new MdcContext<>(id.getMdcKey(), toJson(mdcValue));
} catch (IllegalAccessException | InstantiationException e) {
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
log.error("Cannot put key of type {} to MDC because no new instance of {} can be created: {}",
mdcValue.getClass().getSimpleName(), type.getSimpleName(), e.getMessage());
}
Expand Down

0 comments on commit 56eb80d

Please sign in to comment.