Skip to content

Commit

Permalink
Merge pull request #8 from ctapobep/master
Browse files Browse the repository at this point in the history
[FIXED JENKINS-22150] Corrected performance issue in validation of SCM project.
  • Loading branch information
ctapobep committed Mar 12, 2014
2 parents c6208b9 + eb76597 commit fb110e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
16 changes: 15 additions & 1 deletion pom.xml
Expand Up @@ -28,7 +28,21 @@
</plugins>
</pluginManagement>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
</dependencies>
<scm>
<connection>scm:git:git://github.com/jenkinsci/template-project-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/template-project-plugin.git</developerConnection>
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/hudson/plugins/templateproject/ProxySCM.java
Expand Up @@ -23,6 +23,7 @@
import java.io.File;
import java.io.IOException;

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
Expand Down Expand Up @@ -83,12 +84,15 @@ public String getDisplayName() {
public FormValidation doCheckProjectName(@AncestorInPath AccessControlled anc, @QueryParameter String value) {
// Require CONFIGURE permission on this project
if (!anc.hasPermission(Item.CONFIGURE)) return FormValidation.ok();
Item item = Hudson.getInstance().getItemByFullName(
value, Item.class);
if (item == null) {
//this check is important because otherwise plugin will check for similar project which impacts performance
//the check will be performed even if this plugin is not used as SCM for the current project

This comment has been minimized.

Copy link
@oleg-nenashev

oleg-nenashev Mar 24, 2014

Member

@ctapobep
Just for future...
Please follow the indentation approach of initial code sources and avoid the formatting changes if it is not required. Otherwise, it's quite hard to review changes

This comment has been minimized.

Copy link
@ctapobep

ctapobep Mar 24, 2014

Author Member

Okey-dokey!

if(StringUtils.isEmpty(value)) {
return FormValidation.error("Project cannot be empty");
}
Item item = Hudson.getInstance().getItemByFullName(value, Item.class);
if (item == null) {
return FormValidation.error(Messages.BuildTrigger_NoSuchProject(value,
AbstractProject.findNearest(value)
.getName()));
AbstractProject.findNearest(value).getName()));
}
if (!(item instanceof AbstractProject)) {
return FormValidation.error(Messages.BuildTrigger_NotBuildable(value));
Expand Down

0 comments on commit fb110e4

Please sign in to comment.