Move to_java into java_producer to make push_single signature match MRI

This commit is contained in:
jakesandlund 2015-09-16 15:54:42 +00:00
parent e8703e1df4
commit c29bb5e4d0
3 changed files with 3 additions and 9 deletions

View File

@ -63,8 +63,7 @@ module Hermann
end
if Hermann.jruby?
key = opts.has_key?(:partition_key) ? opts[:partition_key].to_java : nil
result = @internal.push_single(value, topic, key, nil)
result = @internal.push_single(value, topic, opts[:partition_key], nil)
unless result.nil?
@children << result
end

View File

@ -44,6 +44,7 @@ module Hermann
# data to the kafka broker. Upon execution the Promise's status
# will be set
def push_single(msg, topic, key, _)
key = key && key.to_java
Concurrent::Promise.execute {
data = ProducerUtil::KeyedMessage.new(topic, nil, key, msg.to_java_bytes)
begin

View File

@ -68,13 +68,7 @@ describe Hermann::Producer do
end
end
context 'with explicit partition key', :platform => :java do
it 'uses the partition key' do
expect(producer.internal).to receive(:push_single).with(msg, topic, partition_key.to_java, anything)
producer.push(msg, :partition_key => partition_key)
end
end
context 'with explicit partition key', :platform => :mri do
context 'with explicit partition key' do
it 'uses the partition key' do
expect(producer.internal).to receive(:push_single).with(msg, topic, partition_key, anything)
producer.push(msg, :partition_key => partition_key)