Skip to content

Commit

Permalink
Enhance logging for mapper instantiation
Browse files Browse the repository at this point in the history
Signed-off-by: Yannic Klem <Yannic.Klem@bosch.io>
  • Loading branch information
Yannic92 committed Feb 17, 2022
1 parent 3129cfe commit 5bd71d7
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ public Optional<MessageMapper> mapperOf(final String mapperId, final MappingCont
final MessageMapperConfiguration options =
DefaultMessageMapperConfiguration.of(mapperId, configuredAndDefaultOptions,
configuredIncomingConditions, configuredOutgoingConditions);
if (mapper.isEmpty()) {
LOGGER.info("Mapper {} with mapping engine {} not found.", mapperId, mappingContext.getMappingEngine());
}
return mapper.map(WrappingMessageMapper::wrap).flatMap(m -> configureInstance(m, options));
}

Expand Down Expand Up @@ -273,14 +276,18 @@ private static MessageMapper createAnyMessageMapper(final Class<?> clazz,
final Throwable error = mapperTry.failed().get();
if (error instanceof ClassNotFoundException || error instanceof InstantiationException ||
error instanceof ClassCastException) {
LOGGER.warn("Could not instantiate message mapper.", error);
return null;
} else {
throw new IllegalStateException("There was an unknown error when trying to creating instance for '"
+ clazz + "'", error);
}
}

return mapperTry.get();
final MessageMapper messageMapper = mapperTry.get();
if (messageMapper == null) {
LOGGER.warn("Could not instantiate message mapper because result was null.");
}
return messageMapper;
}

private Predicate<? super Map.Entry<String, Class<?>>> requiresNoMandatoryConfiguration() {
Expand Down

0 comments on commit 5bd71d7

Please sign in to comment.