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

Fix ClassCastException for CassandraObservationContext #1541

Closed
wants to merge 1 commit into from

Conversation

cfredri4
Copy link
Contributor

This fixes a ClassCastException for CassandraObservationContext when a NoopObservation is returned by the observation registry.

2024-11-28 10:46:44.837+0100 [s1-admin-0] WARN  c.d.o.d.i.core.tracker.MultiplexingRequestTracker - [warnWithException] [s1|2034963355] Unexpected error while notifying request tracker INSTANCE of an onNodeSuccess event.
java.lang.ClassCastException: class io.micrometer.observation.Observation$Context cannot be cast to class org.springframework.data.cassandra.observability.CassandraObservationContext (io.micrometer.observation.Observation$Context and org.springframework.data.cassandra.observability.CassandraObservationContext are in unnamed module of loader 'app')
	at org.springframework.data.cassandra.observability.ObservationRequestTracker.onNodeSuccess(ObservationRequestTracker.java:109)
	at com.datastax.oss.driver.internal.core.tracker.MultiplexingRequestTracker.lambda$onNodeSuccess$2(MultiplexingRequestTracker.java:114)
	at com.datastax.oss.driver.internal.core.tracker.MultiplexingRequestTracker.invokeTrackers(MultiplexingRequestTracker.java:155)
	at com.datastax.oss.driver.internal.core.tracker.MultiplexingRequestTracker.onNodeSuccess(MultiplexingRequestTracker.java:113)
	at com.datastax.oss.driver.internal.core.cql.CqlRequestHandler.setFinalResult(CqlRequestHandler.java:338)
	at com.datastax.oss.driver.internal.core.cql.CqlRequestHandler.access$1500(CqlRequestHandler.java:97)
	at com.datastax.oss.driver.internal.core.cql.CqlRequestHandler$NodeResponseCallback.lambda$onResponse$1(CqlRequestHandler.java:648)
...
2024-11-28 10:46:44.840+0100 [s1-admin-0] DEBUG o.s.d.c.observability.ObservationRequestTracker - [onSuccess] Closing observation [io.micrometer.observation.NoopObservation@56c0e4a0]
2024-11-28 10:46:44.893+0100 [s1-io-3] WARN  c.d.o.d.i.core.tracker.MultiplexingRequestTracker - [warnWithException] [s1|1865288005] Unexpected error while notifying request tracker INSTANCE of an onNodeSuccess event.
java.lang.ClassCastException: class io.micrometer.observation.Observation$Context cannot be cast to class org.springframework.data.cassandra.observability.CassandraObservationContext (io.micrometer.observation.Observation$Context and org.springframework.data.cassandra.observability.CassandraObservationContext are in unnamed module of loader 'app')
	at org.springframework.data.cassandra.observability.ObservationRequestTracker.onNodeSuccess(ObservationRequestTracker.java:109)
	at com.datastax.oss.driver.internal.core.tracker.MultiplexingRequestTracker.lambda$onNodeSuccess$2(MultiplexingRequestTracker.java:114)
	at com.datastax.oss.driver.internal.core.tracker.MultiplexingRequestTracker.invokeTrackers(MultiplexingRequestTracker.java:155)
	at com.datastax.oss.driver.internal.core.tracker.MultiplexingRequestTracker.onNodeSuccess(MultiplexingRequestTracker.java:113)
	at com.datastax.oss.driver.internal.core.cql.CqlRequestHandler.setFinalResult(CqlRequestHandler.java:338)
	at com.datastax.oss.driver.internal.core.cql.CqlRequestHandler.access$1500(CqlRequestHandler.java:97)
	at com.datastax.oss.driver.internal.core.cql.CqlRequestHandler$NodeResponseCallback.onResponse(CqlRequestHandler.java:657)
...
2024-11-28 10:46:44.905+0100 [s1-io-3] DEBUG o.s.d.c.observability.ObservationRequestTracker - [onSuccess] Closing observation [io.micrometer.observation.NoopObservation@56c0e4a0]

This fixes a ClassCastException for CassandraObservationContext when a NoopObservation is returned by the observation registry.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 28, 2024
@mp911de
Copy link
Member

mp911de commented Nov 28, 2024

Paging @marcingrzejszczak

@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 29, 2024
@mp911de mp911de self-assigned this Nov 29, 2024
mp911de pushed a commit that referenced this pull request Nov 29, 2024
This fixes a ClassCastException for CassandraObservationContext when a NoopObservation is returned by the observation registry.

Closes #1541
mp911de added a commit that referenced this pull request Nov 29, 2024
Extract ifContextPresent(…) utility method to apply contextual actions if the context matches the given type.

See #1541
mp911de pushed a commit that referenced this pull request Nov 29, 2024
This fixes a ClassCastException for CassandraObservationContext when a NoopObservation is returned by the observation registry.

Closes #1541
mp911de added a commit that referenced this pull request Nov 29, 2024
Extract ifContextPresent(…) utility method to apply contextual actions if the context matches the given type.

See #1541
@mp911de mp911de closed this in 74fca38 Nov 29, 2024
mp911de added a commit that referenced this pull request Nov 29, 2024
Extract ifContextPresent(…) utility method to apply contextual actions if the context matches the given type.

See #1541
@mp911de
Copy link
Member

mp911de commented Nov 29, 2024

Thank you for your contribution. That's merged, polished, and backported now.

@mp911de mp911de added this to the 4.3.7 (2024.0.7) milestone Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants