[ 
https://issues.apache.org/jira/browse/OODT-999?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Imesha Sudasingha closed OODT-999.
----------------------------------
       Resolution: Done
    Fix Version/s: 1.9

> File.toURL fails when their are spaces in project/repository paths
> ------------------------------------------------------------------
>
>                 Key: OODT-999
>                 URL: https://issues.apache.org/jira/browse/OODT-999
>             Project: OODT
>          Issue Type: Bug
>            Reporter: Madhawa Vidanapathirana
>            Priority: Major
>             Fix For: 1.9
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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, 
> {noformat}
> <repository 
> path="file:///home/user/Apache%20OODT/cas-filemgr-1.9-SNAPSHOT-dist/data"/>{noformat}
> the ingest operations via client fails with the following log message by 
> filemgr. 
> {code:java}
> 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)
> .... {code}
> A possible way to fix this issue of ingest operation is modifying 
> BasicVersioner.java as follows. 
> {noformat}
> // old code
> // dataStoreRef = new File(new URI(productRepoPath)).toURL()
> // .toExternalForm(); 
> // new code
> dataStoreRef = new File(new URI(productRepoPath)).toURI().toURL() 
> .toExternalForm();{noformat}
> 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. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to