1
我有這個螞蟻目標來驗證,如果一個端口被佔用。該腳本實際上獲得了8080的正確端口,儘管出於某種原因有一條新線。螞蟻javascript和套接字numberformatexception
<loadfile srcfile="hudson.xml" property="port">
<filterchain>
<scriptfilter language="javascript">
if (self.getToken().indexOf("httpPort") != -1)
self.setToken(parseInt(self.getToken().substring((self.getToken().indexOf("httpPort")+9),(self.getToken().indexOf("httpPort")+9) + 4)));
else
self.setToken(null);
</scriptfilter>
<ignoreblank/>
<trim/>
</filterchain>
</loadfile>
<echo message="Checking whether Hudson is running"/>
<condition property="hudson.running">
<socket server="localhost" port="${port}"/>
</condition>
這會拋出一個Numberformatexception。我需要解析這個端口的hudson.xml文件並驗證它目前沒有被使用。有什麼建議?
構建失敗
java.lang.NumberFormatException: For input string: "8080"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.tools.ant.IntrospectionHelper$11.set(IntrospectionHelper.java:1069)
at org.apache.tools.ant.IntrospectionHelper.setAttribute(IntrospectionHelper.java:388)
at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:392)
at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:349)
at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:568)
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:346)
at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:198)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)