Jody Garnett ha scritto:
We should return to the list on this one; I just sent private emails
yesterday in order not to annoy the list with a patch. If I was not so
sleepy i would of attached it to a JIRA (do we have a JIRA?).
Update for the list: We have made some progress with policing the
internal construction of a URI (before it is turned into a URL).
Andrea was promptly horrified and hunted down where some decoding of a
URL was being done and removed that step (allowing some of the
problems to disappear).
Both approaches fix the internal representation of a URL so it is no
longer mangled and can be used to locate a File again. This leaves us
with some locking issues - which may represent a second problem.
I would love some feedback from Jesse on this one (since hey may know
why the encoding/decoding steps were taken?).
Oh, to sum up a little for Jesse: Mac started to add "+" chars into
temp file paths, and the datastore turns those into " " when doing
the url decode portion Jody cites.
I modified the shapefile tests so that + and other ugly chars
end up being part of the path in all platform and consequently
fixed the issue that arose on my linux box.
Unfortunately it seems that does not fix the issue fully on Mac.
See the attached patch.
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Index: src/test/java/org/geotools/data/shapefile/ShapefileReadWriteTest.java
===================================================================
--- src/test/java/org/geotools/data/shapefile/ShapefileReadWriteTest.java (revisione 33377)
+++ src/test/java/org/geotools/data/shapefile/ShapefileReadWriteTest.java (copia locale)
@@ -22,6 +22,8 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
import junit.framework.AssertionFailedError;
@@ -200,8 +202,10 @@
ShapefileDataStore shapefile;
String typeName;
- shapefile = (ShapefileDataStore) maker.createDataStore(tmp.toURL(),
- memorymapped);
+ Map params = new HashMap();
+ params.put(ShapefileDataStoreFactory.URLP.key, tmp.toURI().toURL());
+ params.put(ShapefileDataStoreFactory.MEMORY_MAPPED.key, memorymapped);
+ shapefile = (ShapefileDataStore) maker.createNewShapefile(params);
if(charset != null)
shapefile.setStringCharset(charset);
Index: src/test/java/org/geotools/data/shapefile/TestCaseSupport.java
===================================================================
--- src/test/java/org/geotools/data/shapefile/TestCaseSupport.java (revisione 33377)
+++ src/test/java/org/geotools/data/shapefile/TestCaseSupport.java (copia locale)
@@ -173,7 +173,9 @@
* test suite.
*/
protected File getTempFile() throws IOException {
- File tmpFile = File.createTempFile("test-shp", ".shp");
+ // force in some valid but weird chars into teh path to be on par with OSX that does it
+ // on its own
+ File tmpFile = File.createTempFile("test-+()shp", ".shp");
tmpFile.deleteOnExit();
assertTrue(tmpFile.isFile());
Index: src/main/java/org/geotools/data/shapefile/ShpFileType.java
===================================================================
--- src/main/java/org/geotools/data/shapefile/ShpFileType.java (revisione 33377)
+++ src/main/java/org/geotools/data/shapefile/ShpFileType.java (copia locale)
@@ -109,11 +109,6 @@
* return c:\shapefiles\file1 but all other will return null.
*/
public String toBase(URL url) {
- try {
- return toBase(java.net.URLDecoder.decode(url.toExternalForm(),
- "US-ASCII"));
- } catch (UnsupportedEncodingException e) {
- return toBase(url.toExternalForm());
- }
+ return toBase(url.toExternalForm());
}
}
------------------------------------------------------------------------------
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel