Skip to content

Commit 232849e

Browse files
authored
Replace use of block with lambda to fix wrong number of arguments err… (#75)
* Replace use of block with lambda to fix wrong number of arguments error on jruby-9.3.4.0 on docker This is a strange one. Running tests on docker, prior to this test, the call to when_complete using a block for the BiConsumer parameter would fail with the following error: ``` [2022-06-08T15:31:49,587][ERROR][logstash.inputs.azureeventhubs] Event Hub failed during initialization. {:event_hub_name=>"event_hub_name0", :exception=>#<ArgumentError: wrong number of arguments (given 0, expected 1)>, :backtrace=>["/usr/share/plugins/plugin/lib/logstash/inputs/azure_event_hubs.rb:435:in `block in run'"]} ``` Running the tests locally, this does not fail on my development machine (MacOsX x86_64), but does fail in the dockerized test environment. Attempting to create a simple reproducer against a BiConsumer also does not fail. * Changelog and version bump
1 parent 6e5c9b2 commit 232849e

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.4.4
2+
- Fix: Replace use of block with lambda to fix wrong number of arguments error on jruby-9.3.4.0 [#75](https://github.com/logstash-plugins/logstash-input-azure_event_hubs/pull/75)
3+
14
## 1.4.3
25
- Build: make log4j-api a provided dependency [#73](https://github.com/logstash-plugins/logstash-input-azure_event_hubs/pull/73)
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.3
1+
1.4.4

lib/logstash/inputs/azure_event_hubs.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,25 +432,25 @@ def run(queue)
432432
options.setInitialPositionProvider(LogStash::Inputs::Azure::LookBackPositionProvider.new(@initial_position_look_back))
433433
end
434434
event_processor_host.registerEventProcessorFactory(LogStash::Inputs::Azure::ProcessorFactory.new(queue, event_hub['codec'], event_hub['checkpoint_interval'], self.method(:decorate), event_hub['decorate_events']), options)
435-
.whenComplete {|x, e|
435+
.when_complete(lambda {|x, e|
436436
@logger.info("Event Hub registration complete. ", :event_hub_name => event_hub_name )
437437
@logger.error("Event Hub failure while registering.", :event_hub_name => event_hub_name, :exception => e, :backtrace => e.backtrace) if e
438-
}
439-
.then_accept {|x|
438+
})
439+
.then_accept(lambda {|x|
440440
@logger.info("Event Hub is processing events... ", :event_hub_name => event_hub_name )
441441
# this blocks the completable future chain from progressing, actual work is done via the executor service
442442
while !stop?
443443
Stud.stoppable_sleep(1) {stop?}
444444
end
445-
}
446-
.thenCompose {|x|
445+
})
446+
.then_compose(lambda {|x|
447447
@logger.info("Unregistering Event Hub this can take a while... ", :event_hub_name => event_hub_name )
448448
event_processor_host.unregisterEventProcessor
449-
}
450-
.exceptionally {|e|
449+
})
450+
.exceptionally(lambda {|e|
451451
@logger.error("Event Hub encountered an error.", :event_hub_name => event_hub_name , :exception => e, :backtrace => e.backtrace) if e
452452
nil
453-
}
453+
})
454454
.get # this blocks till all of the futures are complete.
455455
@logger.info("Event Hub #{event_hub_name} is closed.")
456456
rescue => e

0 commit comments

Comments
 (0)