camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cristiano Costantini <>
Subject TypeConverting to null and
Date Wed, 29 May 2013 10:48:08 GMT
Hi All,

I have a custom type converter to a custom data model.

For my purposes, some input types need to be converted to null and  the
exchange need to be processed to add an header even if conversion results
in null.

For example (simplified):

public static MyPayload convert(MessageContentsList message, Exchange
exchange) {
  if (exchange != null) {
  return null;

Well, the first time the converter is invoked it works (the exchange has
the new header),
The second time invokation of "convert" get skipped in
BaseTypeConverterRegistry.doConvertTo(...) as the following if statement
resolves to true:

        // check if we have tried it before and if its a miss
        TypeMapping key = new TypeMapping(type, value.getClass());
        if (misses.containsKey(key)) {
            // we have tried before but we cannot convert this one
            return Void.TYPE;

I've seen that there have been "semantical ambiguity of null"  in the past,
which should have been solved in issue CAMEL-84, but I've not understood it
and how I should handle this scenario in a proper way.

I guess I'm using type converter in a bad style, but as I don't understand
why I can't guess the good way.

The only idea I have is to create a class MyEmptyPayload implements
MyPayload { } and return an instance to this instead of null, but I still
would like to understand the reasons.

Could someone orient me toward the right solution?

Thank you very much,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message