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

Synchronize SPI decorator loading #796

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Conversation

lukasniemeier-zalando
Copy link
Member

Synchronize SPI span decorator loading and have them loaded eagerly.

Motivation and Context

  1. eagerly load decorators obtained via SPI to avoid exceptions in high-concurrency setups
  2. instances of ServiceLoader are not thread-safe, iterating on the Iterable may yield exceptions if done concurrently
  3. eager loading prevents any reloading functionality of ServiceLoader to work

Example exception (sadly ServiceLoaderSpanDecorator not rendered):

java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
	at java.lang.CompoundEnumeration.next(ClassLoader.java:2725)
	at java.lang.CompoundEnumeration.hasMoreElements(ClassLoader.java:2734)
	... 30 frames excluded
	at org.zalando.fauxpas.ThrowingSupplier.get(ThrowingSupplier.java:19)
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at io.opentracing.contrib.concurrent.TracedRunnable.run(TracedRunnable.java:30)
	... 6 frames excluded
	at org.zalando.fauxpas.ThrowingFunction.apply(ThrowingFunction.java:19)
	... 5 frames excluded

See also zalando/riptide#1462 for the same fix

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have added tests to cover my changes.

* eagerly load decorators obtained via SPI to avoid exceptions in
high-concurrency setups
* instances of `ServiceLoader` are not thread-safe, iterating on the
`Iterable` may yield exceptions if done concurrently
* eager loading prevents any reloading functionality of `ServiceLoader`
to work (acceptable)
@lukasniemeier-zalando
Copy link
Member Author

👍

2 similar comments
@andreyors
Copy link

👍🏻

@e101011
Copy link

e101011 commented Aug 14, 2023

👍

@lukasniemeier-zalando lukasniemeier-zalando merged commit 81be1de into main Aug 14, 2023
@lukasniemeier-zalando lukasniemeier-zalando deleted the spi-synchronization branch August 14, 2023 13:43
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.

3 participants