You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2007/06/28 18:04:41 UTC

DO NOT REPLY [Bug 42770] New: - IndexOutOfBounds exception in when the URI is invalid

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42770>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42770

           Summary: IndexOutOfBounds exception in <scp> when the URI is
                    invalid
           Product: Ant
           Version: 1.7Alpha (nightly)
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optional Tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: stevel@apache.org


I'm doing an scp, but the path I am setting up is wrong; its an unexpanded property:

    <property name="ssh.path"
        value="${rpm.ssh.user}@${rpm.ssh.server}:${rpm.ssh.dir}" />
    <scp remoteToDir="${rpm.ssh.path}"
        passphrase="${rpm.ssh.passphrase}"
        keyfile="${rpm.ssh.keyfile}"
        trust="${rpm.ssh.trust}"
        verbose="${rpm.ssh.verbose}" >
      <fileset refid="rpm.upload.fileset"/>
    </scp>

This is breaking the code that cracks the string:

release.rpm-upload:
Property "ssh.server" has not been set
     [echo] SCP target is ${ssh.server}
  [ssh-rpm] Connecting to 16.25.169.163:22
Property "rpm.ssh.path" has not been set

======================================================================
Exiting failing project "release"
======================================================================

BUILD FAILED - at 28/06/07 17:02
/home/slo/Projects/SmartFrog/Forge/core/release/build.xml:547:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:215)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        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)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1938)
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.parseUri(Scp.java:321)
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.upload(Scp.java:253)
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:201)
        ... 16 more
--- Nested Exception ---
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1938)
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.parseUri(Scp.java:321)
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.upload(Scp.java:253)
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:201)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        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)

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 42770] - IndexOutOfBounds exception in when the URI is invalid

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42770>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42770





------- Additional Comments From riznob@hotmail.com  2007-06-28 10:22 -------
What is the expected behavior? In this case the '@' symbol is not found in the 
URI, therefore the java.lang.StringIndexOutOfBoundsException is produced. Do we 
want it to produce a useful error message?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 42770] - IndexOutOfBounds exception in when the URI is invalid

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42770>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42770





------- Additional Comments From stevel@apache.org  2007-06-29 02:55 -------
exactly. we should throw A BuildException saying the path is wrong and including
the value for proper diagnostics. We may also want to do this check in the
setter method, so we can bail out before even connecting (as this makes testing
easier)

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 42770] - IndexOutOfBounds exception in when the URI is invalid

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42770>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42770





------- Additional Comments From sjjohns@cox.net  2007-09-02 13:03 -------
Created an attachment (id=20754)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=20754&action=view)
Patch to throw an appropriate exception when remoteToDir() gets an invalid URI.


Here's a patch that does what Steve mentions.  

I added a check in setRemoteTodir() to throw a BuildException with a
descriptive message when the URI does not contain an '@' symbol.

For good measure, I added some code in parseUri() at the point where the
StringIndexOutOfBoundsException was being thrown to skip the indexOf() call if
the index is negative.	And instead throw a BuildException explaining the
remote URI was invalid.

I also added a unit test to ScpTest.java to exercise the new code.  

While testing the unit test, I found an apparent bug in
ScpTest.testSingleFileUploadAndDownload().  I added a line to fix that. 

Let me know what you think.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org