Skip to content

Conversation

@atsharp
Copy link
Contributor

@atsharp atsharp commented Nov 20, 2020

I noticed while testing some functionality that one of the methods (decorateTaskCallable) mapped via Reflection in LazyTraceScheduledThreadPoolExecutor is incorrect. I believe this should be decorateTask, as that is the method that exists in the ScheduledThreadPoolExecutor delegate.

Similarly, newTaskForCallable also appears to be mapped incorrectly. The only argument to this method is a Callable, yet the Reflection mapper is expecting an Object as well

@codecov
Copy link

codecov bot commented Nov 20, 2020

Codecov Report

Merging #1783 (28982d5) into master (76ad931) will increase coverage by 12.54%.
The diff coverage is 50.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master    #1783       +/-   ##
=============================================
+ Coverage     22.72%   35.26%   +12.54%     
- Complexity      542      814      +272     
=============================================
  Files           263      240       -23     
  Lines          6587     6567       -20     
  Branches        714      726       +12     
=============================================
+ Hits           1497     2316      +819     
+ Misses         4955     4050      -905     
- Partials        135      201       +66     
Impacted Files Coverage Δ Complexity Δ
...nt/async/LazyTraceScheduledThreadPoolExecutor.java 81.15% <50.00%> (ø) 64.00 <0.00> (?)
...ngframework/cloud/sleuth/otel/bridge/OtelSpan.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
...ork/cloud/sleuth/otel/bridge/OtelTraceContext.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
...ork/cloud/sleuth/brave/bridge/BraveScopedSpan.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
...k/cloud/sleuth/otel/bridge/OtelBaggageInScope.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
...k/cloud/sleuth/brave/bridge/BraveTraceContext.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
.../sleuth/brave/sampler/ProbabilityBasedSampler.java 100.00% <0.00%> (ø) 9.00% <0.00%> (ø%)
.../sleuth/instrument/web/servlet/ServletRuntime.java
...rk/cloud/sleuth/instrument/web/TraceWebAspect.java
...strument/web/mvc/TraceContextListenableFuture.java
... and 421 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76ad931...06d4e21. Read the comment docs.

@marcingrzejszczak
Copy link
Contributor

Thanks! Maybe you can write a test to ensure that we don't make this mistake again?

@atsharp
Copy link
Contributor Author

atsharp commented Nov 20, 2020

Thanks! Maybe you can write a test to ensure that we don't make this mistake again?

Will do!

@atsharp
Copy link
Contributor Author

atsharp commented Nov 20, 2020

@marcingrzejszczak I added pretty comprehensive tests for the class in question. Not sure how useful all of them are given that the majority of it is just straightforward delegation, but I figure it's not hurting anything 🤷‍♂️

Copy link
Contributor

@marcingrzejszczak marcingrzejszczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests! I've added one small comment.

Also I'll wait with the merge cause I'm doing some pretty big changes in master. Once I'm done let's come back to this.

BDDAssertions.then(executor.isShutdown()).isFalse();
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we separate given, when and then sections? I can't figure out which line is responsible for calling the actual code to test. I guess it's this one assertThat((Future<?>) executor.decorateTask(runnable, value)).isEqualTo(future); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I'll go ahead and do that. In the example you cite, that statement is both the when and then. It's verifying that the return value for that method matches the delegate's return value. That's not super clear, so let me rework those a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworked the tests a bit. Lemme know what you think

@marcingrzejszczak
Copy link
Contributor

Done via 3c5b490 . Thanks a lot for the PR @atsharp !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants