Skip to content

Instantly share code, notes, and snippets.

@hmedkouri
Created June 11, 2018 16:38
Show Gist options
  • Save hmedkouri/32a4772265d22a8c8227eda5d2a01c08 to your computer and use it in GitHub Desktop.
Save hmedkouri/32a4772265d22a8c8227eda5d2a01c08 to your computer and use it in GitHub Desktop.
Micronaut StackOverflowError when using Guava Eventbus
import com.google.common.eventbus.EventBus
import com.google.common.eventbus.Subscribe
import io.micronaut.context.ApplicationContext
import spock.lang.Specification
import javax.inject.Inject
import javax.inject.Singleton
class EventBusSpec extends Specification {
void "try to reproduce the stack overflow error"(){
expect:
ApplicationContext context = ApplicationContext.run()
context.getBean(Subscriber)
}
@Singleton
static class Subscriber {
static final EventBus eventBus = new EventBus("")
final Service service
@Inject
Subscriber(Service service) {
this.service = service
eventBus.register(this)
}
@Subscribe
void onEvent(String event){
println event
}
}
@Singleton
static class Service {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment