Skip to content

Commit

Permalink
[FIXED JENKINS-15836] Slave's Name should be trimmed of spaces at the…
Browse files Browse the repository at this point in the history
… beginning and end of the Name on Save
  • Loading branch information
ssogabe committed Nov 24, 2012
1 parent 234cd36 commit 41f1fe6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion changelog.html
Expand Up @@ -55,7 +55,10 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Slave's Name should be trimmed of spaces at the beginning and end of the Name on Save.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15836">issue 15836</a>)

</ul>
</div><!--=TRUNK-END=-->

Expand Down
9 changes: 7 additions & 2 deletions core/src/main/java/hudson/model/ComputerSet.java
Expand Up @@ -53,6 +53,7 @@
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.json.JSONObject;

/**
* Serves as the top of {@link Computer}s in the URL hierarchy.
Expand Down Expand Up @@ -262,9 +263,13 @@ public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp
@QueryParameter String type ) throws IOException, ServletException, FormException {
final Jenkins app = Jenkins.getInstance();
app.checkPermission(Computer.CREATE);
checkName(name);
String fixedName = Util.fixEmptyAndTrim(name);
checkName(fixedName);

Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm());
JSONObject formData = req.getSubmittedForm();
formData.put("name", fixedName);

Node result = NodeDescriptor.all().find(type).newInstance(req, formData);
app.addNode(result);

// take the user back to the slave list top page
Expand Down

0 comments on commit 41f1fe6

Please sign in to comment.