Bug 480242 - EventBus not yet set on vertx instance when 'createMetrics(EventBus eventBus)' called on classes implementing implements VertxMetrics
Summary: EventBus not yet set on vertx instance when 'createMetrics(EventBus eventBus)...
Status: NEW
Alias: None
Product: Vertx
Classification: RT
Component: Core (show other bugs)
Version: 3.0.0   Edit
Hardware: PC Mac OS X
: P3 normal
Target Milestone: Unknown   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-20 13:09 EDT by Jeremy Truelove CLA
Modified: 2015-10-20 13:09 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Truelove CLA 2015-10-20 13:09:03 EDT
When implementing VertxMetrics at the point when the event bus createMetrics method is called the eventBus variable is null on the vertx instance. You do get the eventBus variable passed in to you that will be set on the object but it would probably be ideal to make sure this is set beforehand. I tested this on 3.1.0.

public class SomeVertxMetricsImpl implements VertxMetrics {
       
    .....

    public SomeVertxMetricsImpl(SomeMetricsOptions options, Vertx vertx) {
        this.vertx = vertx;
        this.options = new SomeMetricsOptions(options);
    }
 
    .....

    @Override
    public EventBusMetrics createMetrics(EventBus eventBus) {
        // if you access vertx.eventBus() it returns null here, the eventBus var passed in above though is the instance that will be set on the vertx instance it just is a little confusing
    }

    .....

    public HttpClientMetrics<?, ?, ?> createMetrics(HttpClient client, HttpClientOptions options) {
         // if you access vertx.eventBus() here it's valid and not null
    }

    .....
}