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

NoopMetricRegistry.NoopTimer::time(Runnable) should actually run the supplied Runnable #4536

Closed
oxbowlakes opened this issue Oct 21, 2024 · 1 comment · Fixed by #4540 or #4541
Closed

Comments

@oxbowlakes
Copy link

oxbowlakes commented Oct 21, 2024

The implementation of NoopMetricRegistry.NoopTimer's time method which takes a Callable<T> is as follows:

        @Override
        public <T> T time(Callable<T> event) throws Exception {
            return event.call();
        }

However the implementation of the method overload which takes a Runnable is:

        @Override
        public void time(Runnable event) {
            // NOP
        }

This latter implementation is incorrect as the Runnable represents important business logic. That is, switching implementations (e.g. during testing) to a NoopMetricRegistry actually effects the behaviour of the system!

The method body should be as follows:

        @Override
        public void time(Runnable event) {
            event.run();
        }
@joschi
Copy link
Member

joschi commented Oct 21, 2024

@oxbowlakes Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants