提交 90b977ea 编写于 作者: J Jesse Glick 提交者: Oliver Gondža

[JENKINS-35098] Disable AutoBrowserHolder by default to improve the changelog...

[JENKINS-35098] Disable AutoBrowserHolder by default to improve the changelog rendering performance (#2371)

* [FIXED JENKINS-35098] Deleting AutoBrowserHolder.

* Normalizing form binding scheme for AbstractProject.scm.

* At @oleg-nenashev’s insistence, restoring AutoBrowserHolder, though not using it by default.

* Using SystemProperties at @oleg-nenashev’s recommendation.

(cherry picked from commit d33df0f2)
上级 961ab53e
......@@ -37,7 +37,9 @@ import jenkins.model.Jenkins;
*
* <p>
* This class makes such tracking easy by hiding this logic.
* @deprecated Disabled by default: JENKINS-35098
*/
@Deprecated
final class AutoBrowserHolder {
private int cacheGeneration;
private RepositoryBrowser cache;
......
......@@ -31,9 +31,8 @@ import hudson.model.Run;
import hudson.model.TaskListener;
import java.io.File;
import java.io.IOException;
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.DataBoundConstructor;
/**
* No {@link SCM}.
......@@ -41,6 +40,10 @@ import org.kohsuke.stapler.StaplerRequest;
* @author Kohsuke Kawaguchi
*/
public class NullSCM extends SCM {
@DataBoundConstructor
public NullSCM() {}
@Override public SCMRevisionState calcRevisionsFromBuild(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws IOException, InterruptedException {
return null;
}
......@@ -69,9 +72,5 @@ public class NullSCM extends SCM {
return Messages.NullSCM_DisplayName();
}
@Override
public SCM newInstance(StaplerRequest req, JSONObject formData) throws FormException {
return new NullSCM();
}
}
}
......@@ -58,6 +58,7 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
......@@ -84,8 +85,13 @@ import org.kohsuke.stapler.export.ExportedBean;
*/
@ExportedBean
public abstract class SCM implements Describable<SCM>, ExtensionPoint {
/** JENKINS-35098: discouraged */
@SuppressWarnings("FieldMayBeFinal")
private static boolean useAutoBrowserHolder = SystemProperties.getBoolean(SCM.class.getName() + ".useAutoBrowserHolder");
/**
* Stores {@link AutoBrowserHolder}. Lazily created.
* @deprecated Unused by default.
*/
private transient AutoBrowserHolder autoBrowserHolder;
......@@ -124,17 +130,21 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint {
* Returns the applicable {@link RepositoryBrowser} for files
* controlled by this {@link SCM}.
* @see #guessBrowser
* @see SCMDescriptor#isBrowserReusable
*/
@SuppressWarnings("deprecation")
@Exported(name="browser")
public final @CheckForNull RepositoryBrowser<?> getEffectiveBrowser() {
RepositoryBrowser<?> b = getBrowser();
if(b!=null)
return b;
if(autoBrowserHolder==null)
autoBrowserHolder = new AutoBrowserHolder(this);
return autoBrowserHolder.get();
if (useAutoBrowserHolder) {
if (autoBrowserHolder == null) {
autoBrowserHolder = new AutoBrowserHolder(this);
}
return autoBrowserHolder.get();
} else {
return guessBrowser();
}
}
/**
......
......@@ -53,7 +53,9 @@ public abstract class SCMDescriptor<T extends SCM> extends Descriptor<SCM> {
* This is used to invalidate cache of {@link SCM#getEffectiveBrowser}. Due to the lack of synchronization and serialization,
* this field doesn't really count the # of instances created to date,
* but it's good enough for the cache invalidation.
* @deprecated No longer used by default.
*/
@Deprecated
public volatile int generation = 1;
protected SCMDescriptor(Class<T> clazz, Class<? extends RepositoryBrowser> repositoryBrowser) {
......@@ -102,7 +104,9 @@ public abstract class SCMDescriptor<T extends SCM> extends Descriptor<SCM> {
* @return
* true if the two given SCM configurations are similar enough
* that they can reuse {@link RepositoryBrowser} between them.
* @deprecated No longer used by default. {@link SCM#getKey} could be used to implement similar features if needed.
*/
@Deprecated
public boolean isBrowserReusable(T x, T y) {
return false;
}
......
......@@ -54,14 +54,11 @@ public class SCMS {
* @param target
* The project for which this SCM is configured to.
*/
@SuppressWarnings("deprecation")
public static SCM parseSCM(StaplerRequest req, AbstractProject target) throws FormException, ServletException {
String scm = req.getParameter("scm");
if(scm==null) return new NullSCM();
int scmidx = Integer.parseInt(scm);
SCMDescriptor<?> d = SCM._for(target).get(scmidx);
d.generation++;
return d.newInstance(req, req.getSubmittedForm().getJSONObject("scm"));
SCM scm = req.bindJSON(SCM.class, req.getSubmittedForm().getJSONObject("scm"));
scm.getDescriptor().generation++;
return scm;
}
/**
......
......@@ -26,14 +26,14 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:section title="${%Source Code Management}">
<j:set var="scms" value="${h.getSCMDescriptors(it)}" />
<j:forEach var="idx" begin="0" end="${size(scms)-1}">
<j:set var="descriptor" value="${scms[idx]}" />
<!-- Could use f:descriptorRadioList were it not for scm/scmd compatibility code; pending JENKINS-20959 would not help with performance -->
<j:forEach var="descriptor" items="${h.getSCMDescriptors(instance)}" varStatus="loop">
<j:set var="scmd" value="${descriptor}" /><!-- backward compatibility with <1.238 -->
<f:radioBlock name="scm" value="${idx}" title="${scmd.displayName}" checked="${it.scm.descriptor==scmd}">
<j:set var="instance" value="${it.scm.descriptor==descriptor ? it.scm : null}"/>
<f:radioBlock name="scm" help="${descriptor.helpFile}" value="${loop.index}" title="${descriptor.displayName}" checked="${instance.scm.descriptor == descriptor}">
<j:set var="instance" value="${instance.scm.descriptor == descriptor ? it.scm : null}"/>
<j:set var="scm" value="${instance}" /><!-- backward compatibility with <1.238 -->
<st:include from="${scmd}" page="${scmd.configPage}"/>
<f:class-entry descriptor="${descriptor}" />
<st:include from="${descriptor}" page="${descriptor.configPage}" optional="true"/>
</f:radioBlock>
</j:forEach>
</f:section>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册