On Fri, 8 Apr 2022 08:35:12 GMT, Alan Bateman <al...@openjdk.org> wrote:

> Are there examples using URL/URLconnection (rather than ParseUtil directly) 
> to demonstrate the issue?

I’m sorry for the late reply. Thre is the example in  
[JDK-8282395](https://bugs.openjdk.java.net/browse/JDK-8282395).  
This is a simple example code.


import java.net.URL;

public class TestURL {
  public static void main(String args[]) throws Exception {
    URL url = new URL("ftp://.:%@";);
    url.openConnection();
  }
}


The following exception is thrown.


>java TestURL
Exception in thread "main" java.lang.IndexOutOfBoundsException: Range [1, 3) 
out of bounds for length 1
        at 
java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
        at 
java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
        at 
java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
        at java.base/java.util.Objects.checkFromToIndex(Objects.java:411)
        at java.base/java.lang.Integer.parseInt(Integer.java:708)
        at java.base/sun.net.www.ParseUtil.unescape(ParseUtil.java:166)
        at java.base/sun.net.www.ParseUtil.decode(ParseUtil.java:202)
        at 
java.base/sun.net.www.protocol.ftp.FtpURLConnection.<init>(FtpURLConnection.java:203)
        at 
java.base/sun.net.www.protocol.ftp.Handler.openConnection(Handler.java:61)
        at 
java.base/sun.net.www.protocol.ftp.Handler.openConnection(Handler.java:56)
        at java.base/java.net.URL.openConnection(URL.java:1094)
        at TestURL.main(TestURL.java:6)

-------------

PR: https://git.openjdk.java.net/jdk/pull/8155

Reply via email to