question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handling Errors when Topics dont exist

See original GitHub issue

From @tapitoe on December 7, 2018 18:33

Is it possible to handle the error gracefully when topics don’t exist?

Spring Boot: 1.5.14.RELEASE Spring Cloud Stream Dependencies: Ditmars.SR4 Kafka Server: 2.11-1.1.0

Error:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-12-07 10:26:03,921 [restartedMain ] ERROR o.s.b.SpringApplication.reportFailure(ln:771) - Application startup failed org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle'; nested exception is org.springframework.cloud.stream.binder.BinderException: Cannot initialize binder: at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:176) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:880) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE] at abc.xyz.apps.Application.main(Application.java:27) [classes/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_172] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_172] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_172] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_172] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.14.RELEASE.jar:1.5.14.RELEASE] Caused by: org.springframework.cloud.stream.binder.BinderException: Cannot initialize binder: at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.getPartitionsForTopic(KafkaTopicProvisioner.java:271) ~[spring-cloud-stream-binder-kafka-core-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.createConsumerEndpoint(KafkaMessageChannelBinder.java:260) ~[spring-cloud-stream-binder-kafka-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.createConsumerEndpoint(KafkaMessageChannelBinder.java:101) ~[spring-cloud-stream-binder-kafka-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:233) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:66) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.AbstractBinder.bindConsumer(AbstractBinder.java:137) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binding.BindingService.bindConsumer(BindingService.java:97) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binding.BindableProxyFactory.bindInputs(BindableProxyFactory.java:221) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binding.InputBindingLifecycle.start(InputBindingLifecycle.java:55) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] ... 19 more Caused by: java.lang.NullPointerException at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner$2.doWithRetry(KafkaTopicProvisioner.java:252) ~[spring-cloud-stream-binder-kafka-core-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner$2.doWithRetry(KafkaTopicProvisioner.java:246) ~[spring-cloud-stream-binder-kafka-core-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:287) ~[spring-retry-1.2.2.RELEASE.jar:?] at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:164) ~[spring-retry-1.2.2.RELEASE.jar:?] at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.getPartitionsForTopic(KafkaTopicProvisioner.java:246) ~[spring-cloud-stream-binder-kafka-core-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.createConsumerEndpoint(KafkaMessageChannelBinder.java:260) ~[spring-cloud-stream-binder-kafka-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.createConsumerEndpoint(KafkaMessageChannelBinder.java:101) ~[spring-cloud-stream-binder-kafka-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:233) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:66) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binder.AbstractBinder.bindConsumer(AbstractBinder.java:137) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binding.BindingService.bindConsumer(BindingService.java:97) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binding.BindableProxyFactory.bindInputs(BindableProxyFactory.java:221) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.cloud.stream.binding.InputBindingLifecycle.start(InputBindingLifecycle.java:55) ~[spring-cloud-stream-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE] ... 19 more

Copied from original issue: spring-cloud/spring-cloud-stream#1548

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
sobychackocommented, Dec 10, 2018

@tapitoe We are addressing this issue. Thank you for pointing this out.

1reaction
garyrussellcommented, Dec 10, 2018

spring.cloud.stream.kafka.binder.auto-create-topics=false

If you don’t allow auto-creation of topics then they must already exist, period.

We should fail more gracefully than an NPE, though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Definitive Guide to Handling Errors in JavaScript - Kinsta
Getting tripped up by errors in your JavaScript? We'll show you how to tame those errors so you can get back to developing...
Read more >
Clean Code and the Art of Exception Handling - Toptal
Exception Handling : It's a Good Thing · Always create your own ApplicationError hierarchy · Never rescue Exception · Never rescue more exceptions...
Read more >
Error Message Guidelines - Nielsen Norman Group
Good error message should include: Explicit indication that something has gone wrong. The very worst error messages are those that don't exist.
Read more >
Everything you wanted to know about exceptions - PowerShell
An Exception is like an event that is created when normal error handling can't deal with the issue. Trying to divide a number...
Read more >
C# Exception Handling Best Practices - Stackify Blog
At Stackify, we have created a few custom exception types. One good example is a ClientBillingException. Billing is something we don't want to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found