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

Replace JSR-305 annotations with spotbugs annotations #660

Merged
merged 1 commit into from
May 9, 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
@@ -1,7 +1,8 @@
package org.jenkinsci.plugins.prometheus;

import com.cloudbees.simplediskusage.DiskItem;
import com.cloudbees.simplediskusage.JobDiskItem;
import com.cloudbees.simplediskusage.JobDiskItem;
import edu.umd.cs.findbugs.annotations.NonNull;
import io.prometheus.client.Collector;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.prometheus.collectors.CollectorFactory;
Expand All @@ -11,21 +12,20 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.Stream;

public class DiskUsageCollector extends Collector {

private static final Logger LOGGER = LoggerFactory.getLogger(DiskUsageCollector.class);

@Override
@Nonnull
@NonNull
public List<MetricFamilySamples> collect() {

if (!PrometheusConfiguration.get().getCollectDiskUsage()) {
Expand All @@ -37,14 +37,14 @@
} catch (final IOException | RuntimeException e) {
LOGGER.warn("Failed to get disk usage data due to an unexpected error.", e);
return Collections.emptyList();
} catch (final NoClassDefFoundError e) {

Check warning on line 40 in src/main/java/org/jenkinsci/plugins/prometheus/DiskUsageCollector.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 40 is not covered by tests
LOGGER.warn("Cannot collect disk usage data because plugin CloudBees Disk Usage Simple is not installed: {}", e.toString());
LOGGER.info("You can remove this warning if you disable Collect Disk Usage in Prometheus Configuration.");
return Collections.emptyList();
}
}

@Nonnull
@NonNull
private static List<MetricFamilySamples> collectDiskUsage() throws IOException {
final com.cloudbees.simplediskusage.QuickDiskUsagePlugin diskUsagePlugin = Jenkins.get()
.getPlugin(com.cloudbees.simplediskusage.QuickDiskUsagePlugin.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down
Loading