sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1762802 [4/4] - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/util/resources/ ide-project/NetBeans/ storage/ storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ storage/sis-netcdf/src/main/java/org/apach...
Date Thu, 29 Sep 2016 16:11:56 GMT
Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1762802&r1=1762801&r2=1762802&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] Thu Sep 29 16:11:56 2016
@@ -27,6 +27,7 @@ import java.text.ParsePosition;
 import java.text.ParseException;
 import org.opengis.metadata.Metadata;
 import org.opengis.referencing.ReferenceSystem;
+import org.apache.sis.internal.storage.Resources;
 import org.apache.sis.io.wkt.WKTFormat;
 import org.apache.sis.io.wkt.Warnings;
 import org.apache.sis.storage.DataStore;
@@ -50,6 +51,13 @@ import org.apache.sis.referencing.CRS;
  */
 final class Store extends DataStore {
     /**
+     * Arbitrary size limit. Files that big are likely to be something else than WKT,
+     * so this limit allows earlier error reporting than loading huge amount of data
+     * before to detect that those data are not what we taught they are.
+     */
+    private static final int SIZE_LIMIT = 1000000;
+
+    /**
      * The file name.
      */
     private final String name;
@@ -103,8 +111,9 @@ final class Store extends DataStore {
                 int n;
                 while ((n = in.read(buffer, length, buffer.length - length)) >= 0) {
                     if ((length += n) >= buffer.length) {
-                        if (n >= Integer.MAX_VALUE / 1024) {     // Arbitrary size limit.
-                            throw new DataStoreContentException(Errors.format(Errors.Keys.ExcessiveStringSize));
+                        if (n >= SIZE_LIMIT) {
+                            throw new DataStoreContentException(Resources.format(
+                                    Resources.Keys.ExcessiveStringSize_3, name, SIZE_LIMIT,
n));
                         }
                         buffer = Arrays.copyOf(buffer, n << 1);
                     }

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java?rev=1762802&r1=1762801&r2=1762802&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
[UTF-8] Thu Sep 29 16:11:56 2016
@@ -20,9 +20,9 @@ import java.util.List;
 import java.util.LinkedList;
 import java.util.Iterator;
 import java.util.ServiceLoader;
+import org.apache.sis.internal.storage.Resources;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.resources.Errors;
 
 
 /**
@@ -212,7 +212,7 @@ search:         while (!deferred.isEmpty
             }
         }
         if (open && selected == null) {
-            throw new UnsupportedStorageException(Errors.format(Errors.Keys.UnknownFormatFor_1,
connector.getStorageName()));
+            throw new UnsupportedStorageException(Resources.format(Resources.Keys.UnknownFormatFor_1,
connector.getStorageName()));
         }
         return selected;
     }



Mime
View raw message