Fixes MissingConverterException when receiving data with the rabbitmq input plugin (#9984)

* logstash-plugins/logstash-input-rabbitmq#112 Fixes most cases of MissingConverterException when receiving data with the rabbitmq input plugin.

This is adding support for Byte, Short and (most importantly) Date. But to decrease verbosity I use the functionality in fallbackConvert to decode subclasses of the given classes.
See method ValueReader.readFieldValue in java package amqp-client for which types can appear over AMQP (except that LongString is changed to String by March Hare).

* logstash-plugins/logstash-input-rabbitmq#112 Fixes most cases of MissingConverterException when receiving data with the rabbitmq input plugin.

Be verbose instead of using functionality in fallbackConvert for Byte, Short, Integer and Long.
This commit is contained in:
Mårten Svantesson 2018-09-19 11:49:02 +02:00 committed by Guy Boertje
parent 069a42d35e
commit 1a4bdd604f

View file

@ -2,6 +2,7 @@ package org.logstash;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -122,6 +123,8 @@ public final class Valuefier {
);
converters.put(Long.class, LONG_CONVERTER);
converters.put(Integer.class, LONG_CONVERTER);
converters.put(Short.class, LONG_CONVERTER);
converters.put(Byte.class, LONG_CONVERTER);
converters.put(Boolean.class, input -> RubyUtil.RUBY.newBoolean((Boolean) input));
converters.put(
Timestamp.class,
@ -139,6 +142,11 @@ public final class Valuefier {
RubyUtil.RUBY, new Timestamp((DateTime) input)
)
);
converters.put(
Date.class, input -> JrubyTimestampExtLibrary.RubyTimestamp.newRubyTimestamp(
RubyUtil.RUBY, new Timestamp((Date) input)
)
);
converters.put(RubyHash.class, input -> ConvertedMap.newFromRubyHash((RubyHash) input));
converters.put(Map.class, input -> ConvertedMap.newFromMap((Map<String, Object>) input));
converters.put(List.class, input -> ConvertedList.newFromList((List) input));