1 Reply Latest reply on Dec 19, 2013 4:21 PM by baftos

    URI normalization breaks Windows network paths

    1010975

      URI normalization as performed by URI.normalize() breaks Windows network paths such as \\SERVER\path.

       

      This is illustrated by following program:

       

      @Test

      public void uriNormalizationBreaksWindowsNetworkPaths() {


        File file = new File("\\SERVER\path");                           // Replace with an existing file on an network path

        assertThat(file.exists(), is(equalTo(true)));                    // Precondition


        URI uri = file.toURI();                                          // file:////SERVER/path -> correct

        assertThat(new File(uri).exists(), is(equalTo(true)));           // Succeeds


        URI normalizedUri = uri.normalize();                             // file:/SERVER/path -> incorrect

        assertThat(new File(normalizedUri).exists(), is(equalTo(true))); // Fails

      }

       

      It seems to me that this is a bug in the JDK.

      Does anyone know of any utilities that do a better job at normalizing URIs?