Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We have most of the common converters for common Java types in the org.apache.camel.converter package and its children.

Returning null values

By default when using a method in a POJO annotation with @Converter returning null is not a valid response. If null is returned, then Camel will regard that type converter as a miss, and prevent from using it in the future. If null should be allowed as a valid response, then from Camel 2.11.2/2.12.1 onwards you can specify this in the annotation as shown:

Code Block

    @Converter(allowNull = true)
    public static InputStream toInputStream(File file) throws IOException {
        if (file.exist()) {
            return new BufferedInputStream(new FileInputStream(file));
        } else {
            return null;
        }
    }

Discovering Fallback Type Converters

...