Skip to content

Conversation

@saikatcse03
Copy link
Contributor

No description provided.

}

@Override
public void configure(Map<String, ?> configs) {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't using the Baeldung formatter - do you have access to the Baeldung IDE formatter profile? Similar elsewhere

Copy link
Contributor Author

@saikatcse03 saikatcse03 Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it from the earlier baeldung docs and made the changes.

try {
return mapper.writeValueAsBytes(user);
} catch (JsonProcessingException ex) {
log.error("Error deserializing the user {} with exception {}", user, ex.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice is to include the exception as the last parameter to the logger call too so the stack trace is preserved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, i've updated to include it.

try {
return mapper.readValue(bytes, User.class);
} catch (IOException e) {
log.error("Error deserializing the message {} for topic {}", bytes, topic);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice is to include the exception as the last parameter to the logger call too so the stack trace is preserved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, i've updated to include it.

.untilAsserted(() -> {
ConsumerRecords<String, Long> records = consumer.poll(Duration.ofMillis(500));
Map<String, Long> counts = StreamSupport.stream(records.spliterator(), false)
.collect(Collectors.toMap(ConsumerRecord::key, ConsumerRecord::value, (a, b) -> b));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for the (a, b) -> b part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid any map error if duplicate present and so provided with a merge function for resolution. But can be removed as well in our case as duplicate not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants