Skip to content

Commit

Permalink
[JENKINS-72474] Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreffe committed Dec 18, 2023
1 parent b381cc3 commit aa846cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static void scan(Run build, PrintStream scanLog) {
}
}
} catch (Exception e) {
scanLogAction.setException(e);
scanLogAction.setExceptionMessage(e.toString());
logger.log(Level.SEVERE, "Could not scan build " + build, e);
} finally {
scanLogAction.finished();
Expand Down Expand Up @@ -598,8 +598,8 @@ private static List<FoundFailureCause> parseSingleLineCauses(Run build,
} catch (Exception e) {
logToScanLog(scanLog, "Exception during parsing file: " + e);
ScanLogAction logAction = build.getAction(ScanLogAction.class);
if (logAction != null && logAction.getException() == null) {
logAction.setException(e);
if (logAction != null && logAction.getExceptionMessage() == null) {
logAction.setExceptionMessage(e.toString());
}
} finally {
if (reader != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.nio.charset.StandardCharsets;
import jenkins.model.RunAction2;
import org.apache.commons.io.FileUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

Expand All @@ -27,7 +29,7 @@ public class ScanLogAction implements RunAction2 {

private Long endTime;

private Exception exception;
private String exceptionMessage;

/**
* {@inheritDoc}
Expand Down Expand Up @@ -94,24 +96,25 @@ public Long getEndTime() {
/**
* To call when the scan is finished.
*/
public void finished() {
@Restricted(NoExternalUse.class)
protected void finished() {
this.endTime = System.currentTimeMillis();
}

/**
* Get the exception if any.
* Get the exception message if any.
* @return the first exception faced during scan
*/
public Exception getException() {
return exception;
public String getExceptionMessage() {
return exceptionMessage;
}

/**
* Set an exception.
* @param exception the exception to set
* @param exceptionMessage the exception message to set
*/
public void setException(Exception exception) {
this.exception = exception;
public void setExceptionMessage(String exceptionMessage) {
this.exceptionMessage = exceptionMessage;
}

/**
Expand Down

0 comments on commit aa846cf

Please sign in to comment.