Skip to content

Commit

Permalink
Merge #3876 into 3.7.0-M6
Browse files Browse the repository at this point in the history
  • Loading branch information
chemicL committed Aug 22, 2024
2 parents ef152df + b732811 commit 6b71ff0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ public void start() {
delegate.start();
}

@Override
public void init() {
delegate.init();
}

static final class TimedWorker implements Worker {

final TimedScheduler parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package reactor.core.observability.micrometer;

import java.lang.reflect.Field;
import java.time.Duration;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
Expand All @@ -30,7 +28,6 @@
import io.micrometer.core.instrument.LongTaskTimer;
import io.micrometer.core.instrument.MockClock;
import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.internal.DefaultLongTaskTimer;
import io.micrometer.core.instrument.search.RequiredSearch;
import io.micrometer.core.instrument.simple.SimpleConfig;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
Expand Down Expand Up @@ -72,6 +69,60 @@ void closeRegistry() {
registry.close();
}

@Test
void supportsBothDeprecatedAndNonRestartableSchedulers() {
Scheduler deprecatedScheduler = new Scheduler() {

@Override
public Disposable schedule(Runnable task) {
return Disposables.disposed();
}

@Override
public Worker createWorker() {
throw new UnsupportedOperationException();
}
};

Scheduler nonRestartableScheduler = new Scheduler() {
@Override
public Disposable schedule(Runnable task) {
return Disposables.disposed();
}

@Override
public Worker createWorker() {
throw new UnsupportedOperationException();
}

@SuppressWarnings("deprecation")
@Override
public void start() {
throw new UnsupportedOperationException();
}

@Override
public void init() {
}
};

TimedScheduler timedDeprecatedScheduler =
new TimedScheduler(deprecatedScheduler, registry, "test", Tags.empty());

TimedScheduler timedNonRestartableScheduler =
new TimedScheduler(nonRestartableScheduler, registry, "test", Tags.empty());

assertThatNoException().isThrownBy(() -> {
timedDeprecatedScheduler.init();
timedDeprecatedScheduler.start();
});

assertThatNoException().isThrownBy(timedNonRestartableScheduler::init);

assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(timedNonRestartableScheduler::start);
}

@Test
void aDotIsAddedToPrefix() {
TimedScheduler test = new TimedScheduler(Schedulers.immediate(), registry, "noDot", Tags.empty());
Expand Down

0 comments on commit 6b71ff0

Please sign in to comment.