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

build(deps): bump com.github.spotbugs:spotbugs-maven-plugin from 4.7.3.6 to 4.8.2.0 #311

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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<org.jsoup.version>1.16.1</org.jsoup.version>

<com.github.spotbugs.version>4.8.3</com.github.spotbugs.version>
<com.github.spotbugs.plugin.version>4.7.3.6</com.github.spotbugs.plugin.version>
<com.github.spotbugs.plugin.version>4.8.2.0</com.github.spotbugs.plugin.version>
<org.junit.jupiter.version>5.10.1</org.junit.jupiter.version>
<org.hamcrest.version>2.2</org.hamcrest.version>
<org.mockito.version>5.2.0</org.mockito.version>
Expand Down
53 changes: 19 additions & 34 deletions src/main/java/io/cryostat/core/EventOptionsBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package io.cryostat.core;

import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;

import org.openjdk.jmc.common.unit.IConstrainedMap;
import org.openjdk.jmc.common.unit.IConstraint;
Expand All @@ -27,36 +27,26 @@
import org.openjdk.jmc.common.unit.QuantityConversionException;
import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeID;
import org.openjdk.jmc.rjmx.IConnectionHandle;
import org.openjdk.jmc.rjmx.ServiceNotAvailableException;
import org.openjdk.jmc.rjmx.services.jfr.IEventTypeInfo;
import org.openjdk.jmc.rjmx.services.jfr.internal.FlightRecorderServiceV2;

import io.cryostat.core.net.JFRConnection;
import io.cryostat.core.tui.ClientWriter;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public class EventOptionsBuilder {

private final boolean isV2;
private final IMutableConstrainedMap<EventOptionID> map;
private Map<IEventTypeID, Map<String, IOptionDescriptor<?>>> knownTypes;
private Map<String, IEventTypeID> eventIds;

public EventOptionsBuilder(ClientWriter cw, JFRConnection connection, Supplier<Boolean> v2)
throws ServiceNotAvailableException, IOException,
org.openjdk.jmc.rjmx.services.jfr.FlightRecorderException {
this.isV2 = v2.get();
this.map = connection.getService().getDefaultEventOptions().emptyWithSameConstraints();
knownTypes = new HashMap<>();
eventIds = new HashMap<>();
private final Map<IEventTypeID, Map<String, IOptionDescriptor<?>>> knownTypes;
private final Map<String, IEventTypeID> eventIds;

if (!isV2) {
cw.println("Flight Recorder V1 is not supported");
}
public EventOptionsBuilder(
IMutableConstrainedMap<EventOptionID> empty,
Collection<? extends IEventTypeInfo> eventTypes) {
this.map = empty.emptyWithSameConstraints();
this.knownTypes = new HashMap<>();
this.eventIds = new HashMap<>();

for (IEventTypeInfo eventTypeInfo : connection.getService().getAvailableEventTypes()) {
for (IEventTypeInfo eventTypeInfo : eventTypes) {
eventIds.put(
eventTypeInfo.getEventTypeID().getFullKey(), eventTypeInfo.getEventTypeID());
knownTypes.putIfAbsent(
Expand Down Expand Up @@ -87,12 +77,8 @@ static <T, V> V capture(T t) {
return (V) t;
}

@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Field is never mutated")
public IConstrainedMap<EventOptionID> build() {
if (!isV2) {
return null;
}
return map;
return map.mutableCopy();
}

public static class EventTypeException extends Exception {
Expand All @@ -108,18 +94,17 @@ public static class EventOptionException extends Exception {
}

public static class Factory {
private final ClientWriter cw;

public Factory(ClientWriter cw) {
this.cw = cw;
}

public EventOptionsBuilder create(JFRConnection connection)
throws IOException, ServiceNotAvailableException,
org.openjdk.jmc.rjmx.services.jfr.FlightRecorderException {
IConnectionHandle handle = connection.getHandle();
return new EventOptionsBuilder(
cw, connection, () -> FlightRecorderServiceV2.isAvailable(handle));
if (!FlightRecorderServiceV2.isAvailable(connection.getHandle())) {
throw new UnsupportedOperationException("Only FlightRecorder V2 is supported");
}
IMutableConstrainedMap<EventOptionID> empty =
connection.getService().getDefaultEventOptions().emptyWithSameConstraints();
Collection<? extends IEventTypeInfo> eventTypes =
connection.getService().getAvailableEventTypes();
return new EventOptionsBuilder(empty, eventTypes);
}
}
}
3 changes: 1 addition & 2 deletions src/main/java/io/cryostat/core/agent/AgentJMXHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import javax.management.ObjectName;
import javax.management.ReflectionException;

import org.openjdk.jmc.rjmx.ConnectionException;
import org.openjdk.jmc.rjmx.IConnectionHandle;

public class AgentJMXHelper {
Expand All @@ -41,7 +40,7 @@ public class AgentJMXHelper {
private final IConnectionHandle connectionHandle;
private final MBeanServerConnection mbsc;

public AgentJMXHelper(IConnectionHandle connectionHandle) throws ConnectionException {
public AgentJMXHelper(IConnectionHandle connectionHandle) {
this.connectionHandle = connectionHandle;
mbsc = connectionHandle.getServiceOrDummy(MBeanServerConnection.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public LocalProbeTemplateService(FileSystem fs, Environment env) throws IOExcept
}
}

protected final void finalize() {}

public ProbeTemplate addTemplate(InputStream inputStream, String filename)
throws FileAlreadyExistsException, IOException, SAXException {
Path path = fs.pathOf(env.getEnv(TEMPLATE_PATH), filename);
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/io/cryostat/core/net/JFRJMXConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public class JFRJMXConnection implements JFRConnection {
FileSystem fs,
Environment env,
IConnectionDescriptor cd,
List<Runnable> listeners)
throws ConnectionException {
List<Runnable> listeners) {
this.cw = cw;
this.fs = fs;
this.env = env;
Expand All @@ -87,8 +86,7 @@ public class JFRJMXConnection implements JFRConnection {
this.serviceFactory = new FlightRecorderServiceFactory();
}

JFRJMXConnection(ClientWriter cw, FileSystem fs, Environment env, IConnectionDescriptor cd)
throws ConnectionException {
JFRJMXConnection(ClientWriter cw, FileSystem fs, Environment env, IConnectionDescriptor cd) {
this(cw, fs, env, cd, List.of());
}

Expand All @@ -108,7 +106,7 @@ public synchronized IConnectionHandle getHandle() throws ConnectionException, IO

public synchronized CryostatFlightRecorderService getService()
throws ConnectionException, IOException, ServiceNotAvailableException {
return new JmxFlightRecorderService(this, cw);
return new JmxFlightRecorderService(this);
}

public TemplateService getTemplateService() {
Expand Down
Loading
Loading