Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException thrown if meta.id is not found in a consumed event #453

Open
Christoffer-Cortes opened this issue Apr 17, 2020 · 1 comment
Labels
bug Something is wrong and needs fixing. good first issue Good for newcomers.

Comments

@Christoffer-Cortes
Copy link
Contributor

Christoffer-Cortes commented Apr 17, 2020

Description

EventHandler throwns a NullPointerException if the meta.id field is not found in consumed event. This can be done better with the event being ignored and better message in the log.
There is no actual validation of the event with a schema and it is this way by design to allow technically any type of protocol.

Motivation

A better explanation in the log.

Exemplification

Benefits

Possible Drawbacks

@Christoffer-Cortes Christoffer-Cortes added bug Something is wrong and needs fixing. good first issue Good for newcomers. labels Apr 17, 2020
@e-pettersson-ericsson
Copy link
Member

The class EventHandler contains the method onMessage, where this bug needs to be fixed.

    @Async
    public void onMessage(Message message, Channel channel) throws Exception {
        String messageBody = new String(message.getBody());
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode node = objectMapper.readTree(messageBody);
        String id = node.get("meta").get("id").toString();
        String port = environment.getProperty("local.server.port");
        Thread.currentThread().setName(Thread.currentThread().getName() + "-" + port);
        LOGGER.debug("Thread id {} spawned for EventHandler on port: {}", Thread.currentThread().getId(), port);
        LOGGER.debug("Event {} received on port {}", id, port);

It would be nice if line 4 could be broken out to a separate method. (Makes it easier to test)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is wrong and needs fixing. good first issue Good for newcomers.
Projects
None yet
Development

No branches or pull requests

2 participants