提交 fe9b035b 编写于 作者: M mindless

[FIXED HUDSON-2110] Improved validation and help text regarding when number of

executors setting may be zero.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@18731 71c3de6d-444a-0410-be80-ed276b4c234a
上级 a7ac4b05
...@@ -1423,6 +1423,10 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl ...@@ -1423,6 +1423,10 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
return false; return false;
} }
public FormValidation doCheckNumExecutors(@QueryParameter String value) {
return FormValidation.validateNonNegativeInteger(value);
}
// to route /descriptor/FQCN/xxx to getDescriptor(FQCN).xxx // to route /descriptor/FQCN/xxx to getDescriptor(FQCN).xxx
public Object getDynamic(String token) { public Object getDynamic(String token) {
return Hudson.getInstance().getDescriptor(token); return Hudson.getInstance().getDescriptor(token);
......
...@@ -427,7 +427,7 @@ public abstract class Slave extends Node implements Serializable { ...@@ -427,7 +427,7 @@ public abstract class Slave extends Node implements Serializable {
public static abstract class SlaveDescriptor extends NodeDescriptor { public static abstract class SlaveDescriptor extends NodeDescriptor {
public FormValidation doCheckNumExecutors(@QueryParameter String value) { public FormValidation doCheckNumExecutors(@QueryParameter String value) {
return FormValidation.validateNonNegativeInteger(value); return FormValidation.validatePositiveInteger(value);
} }
/** /**
......
...@@ -299,6 +299,19 @@ public abstract class FormValidation extends IOException implements HttpResponse ...@@ -299,6 +299,19 @@ public abstract class FormValidation extends IOException implements HttpResponse
public static FormValidation validateNonNegativeInteger(String value) { public static FormValidation validateNonNegativeInteger(String value) {
try { try {
if(Integer.parseInt(value)<0) if(Integer.parseInt(value)<0)
return error(hudson.model.Messages.Hudson_NotANonNegativeNumber());
return ok();
} catch (NumberFormatException e) {
return error(hudson.model.Messages.Hudson_NotANumber());
}
}
/**
* Makes sure that the given string is a positive integer.
*/
public static FormValidation validatePositiveInteger(String value) {
try {
if(Integer.parseInt(value)<=0)
return error(hudson.model.Messages.Hudson_NotAPositiveNumber()); return error(hudson.model.Messages.Hudson_NotAPositiveNumber());
return ok(); return ok();
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
......
...@@ -88,6 +88,7 @@ Hudson.ViewAlreadyExists=A view already exists with the name "{0}" ...@@ -88,6 +88,7 @@ Hudson.ViewAlreadyExists=A view already exists with the name "{0}"
Hudson.ViewName=All Hudson.ViewName=All
Hudson.NotANumber=Not a number Hudson.NotANumber=Not a number
Hudson.NotAPositiveNumber=Not a positive number Hudson.NotAPositiveNumber=Not a positive number
Hudson.NotANonNegativeNumber=Number may not be negative
Hudson.NotANegativeNumber=Not a negative number Hudson.NotANegativeNumber=Not a negative number
Hudson.NotUsesUTF8ToDecodeURL=\ Hudson.NotUsesUTF8ToDecodeURL=\
Your container doesn''t use UTF-8 to decode URLs. If you use non-ASCII characters as a job name etc, \ Your container doesn''t use UTF-8 to decode URLs. If you use non-ASCII characters as a job name etc, \
......
...@@ -10,5 +10,6 @@ ...@@ -10,5 +10,6 @@
<p> <p>
When using Hudson in the master/slave mode, setting this value to 0 would prevent the master When using Hudson in the master/slave mode, setting this value to 0 would prevent the master
to do any build on its own. from doing any building on its own. Slaves may not have zero executors, but may be
</div> temporarily disabled using the button on the slave's status page.
\ No newline at end of file </div>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册