diff --git a/core/src/main/java/hudson/scm/AutoBrowserHolder.java b/core/src/main/java/hudson/scm/AutoBrowserHolder.java
index 9f6dd18024f6f83aec47fc40260a5005a69a7d21..10e03cb0f64af8ffa641ffd05b65f65212f752e9 100644
--- a/core/src/main/java/hudson/scm/AutoBrowserHolder.java
+++ b/core/src/main/java/hudson/scm/AutoBrowserHolder.java
@@ -37,7 +37,9 @@ import jenkins.model.Jenkins;
*
*
* 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;
diff --git a/core/src/main/java/hudson/scm/NullSCM.java b/core/src/main/java/hudson/scm/NullSCM.java
index 911bac13a0615a46d1011b77935b80fd4b1ae497..777db3759e47442b2913f62e0a18076c780e2f69 100644
--- a/core/src/main/java/hudson/scm/NullSCM.java
+++ b/core/src/main/java/hudson/scm/NullSCM.java
@@ -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();
- }
}
}
diff --git a/core/src/main/java/hudson/scm/SCM.java b/core/src/main/java/hudson/scm/SCM.java
index ce9d7a6762a3ba07ece7a6035ec8ce0061443b98..2cf33416658b9ad63725b6ea95920e96a94aac09 100644
--- a/core/src/main/java/hudson/scm/SCM.java
+++ b/core/src/main/java/hudson/scm/SCM.java
@@ -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, 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, 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();
+ }
}
/**
diff --git a/core/src/main/java/hudson/scm/SCMDescriptor.java b/core/src/main/java/hudson/scm/SCMDescriptor.java
index 242ad88c6d518ca9f43919b39e47c47dad9e6aa2..9929e95d3ae7a06f35fec779d4fb1ed39e775997 100644
--- a/core/src/main/java/hudson/scm/SCMDescriptor.java
+++ b/core/src/main/java/hudson/scm/SCMDescriptor.java
@@ -53,7 +53,9 @@ public abstract class SCMDescriptor extends Descriptor {
* 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 clazz, Class extends RepositoryBrowser> repositoryBrowser) {
@@ -102,7 +104,9 @@ public abstract class SCMDescriptor extends Descriptor {
* @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;
}
diff --git a/core/src/main/java/hudson/scm/SCMS.java b/core/src/main/java/hudson/scm/SCMS.java
index e79af364de0155313afcd770524439d8356cb410..4f7f71e4b186d022718aae869fd630c980912eb8 100644
--- a/core/src/main/java/hudson/scm/SCMS.java
+++ b/core/src/main/java/hudson/scm/SCMS.java
@@ -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;
}
/**
diff --git a/core/src/main/resources/lib/hudson/project/config-scm.jelly b/core/src/main/resources/lib/hudson/project/config-scm.jelly
index 6874bb2dfb9105526635d239d5b43bdb0214b177..0d3eb3bf1f022ee5b8c898dfc2affd44749dbf92 100644
--- a/core/src/main/resources/lib/hudson/project/config-scm.jelly
+++ b/core/src/main/resources/lib/hudson/project/config-scm.jelly
@@ -26,14 +26,14 @@ THE SOFTWARE.
-
-
-
+
+
-
-
+
+
-
+
+