Skip to content

IndexOutOfBoundsException when setting custom sender #1637

@codefromthecrypt

Description

@codefromthecrypt

Describe the bug
@jennings1716 has been valiantly trying to use kinesis sender. If you follow the docs and override the bean it crashes

https://cloud.spring.io/spring-cloud-sleuth/reference/html/#overriding-the-auto-configuration-of-zipkin

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [zipkin2.reporter.Reporter]: Factory method 'reporter' threw exception; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	... 99 common frames omitted
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[na:1.8.0_181]
	at java.util.ArrayList.get(ArrayList.java:433) ~[na:1.8.0_181]
	at org.springframework.cloud.sleuth.zipkin2.ZipkinBackwardsCompatibilityAutoConfiguration$BackwardsCompatibilityConfiguration.reporter(ZipkinBackwardsCompatibilityAutoConfiguration.java:102) ~[spring-cloud-sleuth-zipkin-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	... 100 common frames omitted

Incidentally, if you also override the AsyncReporter, it is fine, but this is a bad experience also We will stop using AsyncReporter anyway so it is a bad idea to spaghetti around this bug.

Sample
set the sender as in the docs == crash, also set the async reporter == not crash

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions