Skip to content

Commit

Permalink
[JENKINS-49586] - Stop serializing JDependParser to the disk
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev committed Feb 16, 2018
1 parent baad820 commit 54a2c37
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
50 changes: 42 additions & 8 deletions src/main/java/hudson/plugins/jdepend/JDependBuildAction.java
Expand Up @@ -8,23 +8,35 @@

import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.model.Run;
import jenkins.model.RunAction2;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.CheckForNull;

/**
* A build action to generate JDepend HTML reports
* @author cflewis
*
*/
public class JDependBuildAction implements Action
public class JDependBuildAction implements RunAction2
{
public final AbstractBuild<?, ?> build;
private final JDependParser jDependParser;
private String htmlReport;

public JDependBuildAction(AbstractBuild<?, ?> build, JDependParser jDependParser)
private transient Run<?,?> owner;

public JDependBuildAction(JDependParser jDependParser) {
this(null, jDependParser);
}

/**
* @deprecated Use {@link #JDependBuildAction(JDependParser)}
*/
@Deprecated
public JDependBuildAction(@CheckForNull AbstractBuild<?, ?> build, JDependParser jDependParser)
{
super();
this.build = build;
this.jDependParser = jDependParser;
this.owner = build;
JDependReporter r = new JDependReporter(jDependParser);

try {
Expand Down Expand Up @@ -79,7 +91,29 @@ public String getJDependHtml() {
return htmlReport;
}

/**
* Gets current parser.
* Not persisted over the restart.
* @return Always {@code null}
*/
@Deprecated
@CheckForNull
public JDependParser getJDependParser() {
return jDependParser;
return null;
}

@Override
public void onAttached(Run<?, ?> r) {
this.owner = r;
}

@Override
public void onLoad(Run<?, ?> r) {
this.owner = r;
}

@Restricted(NoExternalUse.class)
public Run<?, ?> getOwner() {
return owner;
}
}
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/jdepend/JDependRecorder.java
Expand Up @@ -154,7 +154,7 @@ protected boolean generateJDependReport(AbstractBuild<?, ?> build,
!configuredJDependFile.matches("(\\s)?")) {
p = getConfiguredParser(build, configuredJDependFile);

build.getActions().add(new JDependBuildAction(build, p));
build.addAction(new JDependBuildAction(p));
return true;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ protected boolean generateJDependReport(AbstractBuild<?, ?> build,
log("Couldn't generate JDepend file " + e);
}

build.getActions().add(new JDependBuildAction(build, p));
build.addAction(new JDependBuildAction(p));

/**
* Attempt to delete the temp files. If the source JDepend worked on
Expand Down
Expand Up @@ -26,7 +26,7 @@
}
</style>
</l:header>
<st:include it="${it.build}" page="sidepanel.jelly" />
<st:include it="${it.owner}" page="sidepanel.jelly" />

<l:main-panel>
<j:out value="${it.getJDependHtml()}"/>
Expand Down

0 comments on commit 54a2c37

Please sign in to comment.