Uploaded image for project: 'OODT (Retired)'
  1. OODT (Retired)
  2. OODT-999

File.toURL fails when their are spaces in project/repository paths

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Done
    • None
    • 1.9
    • None
    • None
    • Don't Know (Unsure) - The default level

    Description

      The method File.toURL which is now deprecated by Java has been used in many places of the code.

      The javadoc for File.toURL method explains as follows

      @deprecated This method does not automatically escape characters that
      * are illegal in URLs. It is recommended that new code convert an
      * abstract pathname into a URL by first converting it into a URI, via the
      * {@link #toURI() toURI} method, and then converting the URI into a URL
      * via the {@link java.net.URI#toURL() URI.toURL} method.

      This method causes ingest operations to fail when repository path contains spaces. 

      E.g. If specified in product_types.xml as follows, 

      <repository path="file:///home/user/Apache%20OODT/cas-filemgr-1.9-SNAPSHOT-dist/data"/>

      the ingest operations via client fails with the following log message by filemgr. 

      WARNING: URISyntaxException getting URI from URI str: [file:/home/madhawa/Apache OODT/cas-filemgr-1.9-SNAPSHOT-dist/data/blah.txt/blah.txt]
      java.lang.NullPointerException
      at java.io.File.<init>(File.java:277)
      at org.apache.oodt.cas.filemgr.metadata.extractors.examples.FinalFileLocationExtractor.doExtract(FinalFileLocationExtractor.java:90)
      at org.apache.oodt.cas.filemgr.metadata.extractors.AbstractFilemgrMetExtractor.extractMetadata(AbstractFilemgrMetExtractor.java:61)
      at org.apache.oodt.cas.filemgr.system.FileManager.runExtractors(FileManager.java:875)
      at org.apache.oodt.cas.filemgr.system.FileManager.addMetadata(FileManager.java:829)
      at org.apache.oodt.cas.filemgr.system.FileManager.ingestProduct(FileManager.java:553)
      at org.apache.oodt.cas.filemgr.system.AvroFileManagerServer.ingestProduct(AvroFileManagerServer.java:468)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.apache.avro.ipc.specific.SpecificResponder.respond(SpecificResponder.java:91)
      at org.apache.avro.ipc.Responder.respond(Responder.java:151)
      at org.apache.avro.ipc.NettyServer$NettyServerAvroHandler.messageReceived(NettyServer.java:188)
      .... 

      A possible way to fix this issue of ingest operation is modifying BasicVersioner.java as follows. 

      // old code
      // dataStoreRef = new File(new URI(productRepoPath)).toURL()
      // .toExternalForm(); 
      
      // new code
      dataStoreRef = new File(new URI(productRepoPath)).toURI().toURL() .toExternalForm();

      However, other locations where this deprecated method is being used may cause other operations to fail as well.  For example, multiple unit tests of the project fails if the code is cloned to a path that contain spaces. 

      I am currently working on a fix for this issue. But I may have to modify some unit tests as well in order to make them work when source path contains spaces. 

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              madhawav Madhawa Vidanapathirana
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m

                  Slack

                    Issue deployment