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

chore(logger): do not pass logger instances into constructors #354

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
import org.openjdk.jmc.jdp.client.JDPClient;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JvmDiscoveryClient {

private final Logger logger;
private final Logger logger = LoggerFactory.getLogger(getClass());
private final JDPClient jdp;
private final Set<Consumer<JvmDiscoveryEvent>> eventListeners;
private final DiscoveryListener listener;

// package-private for testing
JvmDiscoveryClient(JDPClient jdp, Logger logger) {
JvmDiscoveryClient(JDPClient jdp) {
this.jdp = jdp;
this.logger = logger;
this.eventListeners = new HashSet<>();
this.listener =
new DiscoveryListener() {
Expand Down Expand Up @@ -74,8 +74,8 @@ public void onDiscovery(DiscoveryEvent evt) {
};
}

public JvmDiscoveryClient(Logger logger) {
this(new JDPClient(), logger);
public JvmDiscoveryClient() {
this(new JDPClient());
}

public void start() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.io.input.CountingInputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Re-implementation of {@link ReportGenerator} where the report generation task is represented by a
Expand All @@ -72,14 +73,13 @@ public class InterruptibleReportGenerator {

private final ExecutorService qThread = Executors.newCachedThreadPool();
private final ExecutorService executor;
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger(getClass());

@SuppressFBWarnings(
value = "EI_EXPOSE_REP2",
justification = "fields are not exposed since there are no getters")
public InterruptibleReportGenerator(ExecutorService executor, Logger logger) {
public InterruptibleReportGenerator(ExecutorService executor) {
this.executor = executor;
this.logger = logger;
}

public Future<Map<String, AnalysisResult>> generateEvalMapInterruptibly(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,16 @@
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ExtendWith(MockitoExtension.class)
class JvmDiscoveryClientTest {

JvmDiscoveryClient client;
@Mock JDPClient jdp;
@Mock Logger logger = LoggerFactory.getLogger(getClass());

@BeforeEach
void setup() {
this.client = new JvmDiscoveryClient(jdp, logger);
this.client = new JvmDiscoveryClient(jdp);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,17 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ExtendWith(MockitoExtension.class)
class InterruptibleReportGeneratorTest {

@Mock InputStream recording;
@Mock Logger logger = LoggerFactory.getLogger(getClass());

InterruptibleReportGenerator generator;

@BeforeEach()
void setup() throws Exception {
generator = new InterruptibleReportGenerator(Executors.newWorkStealingPool(1), logger);
generator = new InterruptibleReportGenerator(Executors.newWorkStealingPool(1));
}

@Test
Expand Down
Loading