Revision: 5808
          http://sourceforge.net/p/jump-pilot/code/5808
Author:   michaudm
Date:     2018-05-27 07:37:30 +0000 (Sun, 27 May 2018)
Log Message:
-----------
Save as shapefile was throwing a silent exception because it tried to open an 
input stream on an url which did not yet exist.

Modified Paths:
--------------
    core/trunk/src/org/geotools/shapefile/Shapefile.java

Modified: core/trunk/src/org/geotools/shapefile/Shapefile.java
===================================================================
--- core/trunk/src/org/geotools/shapefile/Shapefile.java        2018-05-21 
13:38:57 UTC (rev 5807)
+++ core/trunk/src/org/geotools/shapefile/Shapefile.java        2018-05-27 
07:37:30 UTC (rev 5808)
@@ -60,15 +60,15 @@
      */
     public Shapefile(URL url) {
         baseURL=url;
-        shpInputStream= null;
-        try {
-            URLConnection uc = baseURL.openConnection();
-            // a 16 kb buffer may be up to 20% faster than the default 2 kb 
buffer
-            shpInputStream = new BufferedInputStream(uc.getInputStream(), 
16*1024);
-        }
-        catch (Exception e){
-            Logger.error(e);
-        }
+        //shpInputStream= null;
+        //try {
+        //    URLConnection uc = baseURL.openConnection();
+        //    // a 16 kb buffer may be up to 20% faster than the default 2 kb 
buffer
+        //    shpInputStream = new BufferedInputStream(uc.getInputStream(), 
16*1024);
+        //}
+        //catch (Exception e){
+        //    Logger.error(e);
+        //}
     }
     
     public Shapefile(InputStream is) {
@@ -77,14 +77,22 @@
     
     public void close() {
         try {
-            shpInputStream.close();
-       }
-       catch (IOException ex){
+            if (shpInputStream != null) shpInputStream.close();
+         }
+         catch (IOException ex){
             Logger.error(ex);
         }
     }
     
     private EndianDataInputStream getInputStream() throws IOException {
+        try {
+            URLConnection uc = baseURL.openConnection();
+            // a 16 kb buffer may be up to 20% faster than the default 2 kb 
buffer
+            shpInputStream = new BufferedInputStream(uc.getInputStream(), 
16*1024);
+        }
+        catch (Exception e){
+            Logger.error(e);
+        }
         if (shpInputStream == null) {
             throw new IOException("Couldn't make a connection to the URL: " + 
baseURL);
         }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to