Skip to content

Commit

Permalink
Run spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Matsuoka committed Feb 28, 2025
1 parent 1771c41 commit 5c0c415
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/main/java/io/cryostat/jmcagent/S3ProbeTemplateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,31 @@ public class S3ProbeTemplateService implements ProbeTemplateService {
private static final String TEMPLATE_DELETED_CATEGORY = "ProbeTemplateDeleted";
private static final String TEMPLATE_UPLOADED_CATEGORY = "ProbeTemplateUploaded";


void onStart(@Observes StartupEvent evt) {
storageBuckets.createIfNecessary(bucket);
if (!checkDir()) {
return;
return;
}
try {
Files.walk(dir)
.filter(Files::isRegularFile)
.filter(Files::isReadable)
.forEach(
path -> {
try (var is = Files.newInputStream(path)) {
logger.debugv("Uploading probe template from {0} to S3", path.toString());
addTemplate(is, path.toString());
} catch (IOException | SAXException e) {
logger.error(e);
} catch (DuplicateProbeTemplateException e) {
logger.warn(e);
}
});
} catch (IOException e) {
logger.warn(e);
}
Files.walk(dir)
.filter(Files::isRegularFile)
.filter(Files::isReadable)
.forEach(
path -> {
try (var is = Files.newInputStream(path)) {
logger.debugv(
"Uploading probe template from {0} to S3",
path.toString());
addTemplate(is, path.toString());
} catch (IOException | SAXException e) {
logger.error(e);
} catch (DuplicateProbeTemplateException e) {
logger.warn(e);
}
});
} catch (IOException e) {
logger.warn(e);
}
}

private boolean checkDir() {
Expand Down Expand Up @@ -222,7 +223,8 @@ public ProbeTemplate addTemplate(InputStream stream, String fileName)
template.setFileName(fileName);
template.deserialize(stream);
var existing = getTemplates();
if (existing.stream().anyMatch(t -> Objects.equals(t.getFileName(), template.getFileName()))) {
if (existing.stream()
.anyMatch(t -> Objects.equals(t.getFileName(), template.getFileName()))) {
throw new DuplicateProbeTemplateException(template.getFileName());
}
storage.putObject(
Expand Down

0 comments on commit 5c0c415

Please sign in to comment.