Skip to content

Commit

Permalink
Resolve findbugs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszsek committed May 28, 2018
1 parent 0243dd2 commit 99e37fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Expand Up @@ -78,7 +78,9 @@ public void doFilter(ServletRequest request, ServletResponse res, FilterChain ch
if (uri.startsWith("/queue/item/")) try {
extra = " (" + Jenkins.getInstance().getQueue().getItem(Integer.parseInt(
uri.substring(12, uri.indexOf('/', 13)))).task.getUrl() + ')';
} catch (Exception ignore) { }
} catch (Exception e) {
LOGGER.log(Level.FINEST, "Error occurred during parsing queue item", e);
}

if(LOGGER.isLoggable(Level.FINE))
LOGGER.log(Level.FINE, "Audit request {0} by user {1}", new Object[]{uri, username});
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/hudson/plugins/audit_trail/AuditTrailPlugin.java
Expand Up @@ -122,6 +122,7 @@ public void onFinalized(Run run) {
}

}

public void onFinalized(AbstractBuild build) {
if (this.started) {
StringBuilder causeBuilder = new StringBuilder(100);
Expand All @@ -136,7 +137,7 @@ public void onFinalized(AbstractBuild build) {
for (AuditLogger logger : loggers) {
String message = build.getFullDisplayName() +
" " + causeBuilder.toString() +
" on node " + (build.getBuiltOn() == null ? "#unknown#" : build.getBuiltOn().getDisplayName()) +
" on node " + buildNodeName(build) +
" started at " + build.getTimestampString2() +
" completed in " + build.getDuration() + "ms" +
" completed: " + build.getResult();
Expand All @@ -146,6 +147,15 @@ public void onFinalized(AbstractBuild build) {
}
}

private String buildNodeName(AbstractBuild build) {
Node node = build.getBuiltOn();
if (node != null) {
return node.getDisplayName();
}

return "#unknown#";
}

/* package */ void onRequest(String uri, String extra, String username) {
if (this.started) {
for (AuditLogger logger : loggers) {
Expand Down

0 comments on commit 99e37fc

Please sign in to comment.