sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1735699 - in /sis/branches/JDK8: application/sis-console/src/main/artifact/conf/ core/sis-referencing/src/main/java/org/apache/sis/referencing/ core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ core/sis-referencing/src...
Date Fri, 18 Mar 2016 22:40:15 GMT
Author: desruisseaux
Date: Fri Mar 18 22:40:14 2016
New Revision: 1735699

URL: http://svn.apache.org/viewvc?rev=1735699&view=rev
Log:
Try to provide a litte bit more information in the logging messages,
especially when we failed to create or connect to the EPSG database.

Modified:
    sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java
    sis/branches/JDK8/src/main/config/logging.properties
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DataTransfer.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/HyperRectangleReader.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryDataTransfer.java
    sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/HyperRectangleReaderTest.java

Modified: sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties [ISO-8859-1] Fri Mar 18 22:40:14 2016
@@ -56,7 +56,7 @@ java.util.logging.ConsoleHandler.level =
 # source: If set, writes the source logger or the source class name.
 #         The argument specifies the type of source to display.
 #         Valid values are none, logger:short, logger:long,
-#         class:short and class:long.
+#         "class:short", "class:long" and "class.method".
 
 java.util.logging.ConsoleHandler.formatter = org.apache.sis.util.logging.MonolineFormatter
 org.apache.sis.util.logging.MonolineFormatter.source = logger:long

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -110,7 +110,7 @@ final class AuthorityFactories<T extends
             if (factory == null) try {
                 factory = new EPSGFactory(null);
             } catch (FactoryException e) {
-                log(Level.CONFIG, e);
+                log(e, false);
                 factory = EPSGFactoryFallback.INSTANCE;
             }
             EPSG[0] = factory;
@@ -137,37 +137,42 @@ final class AuthorityFactories<T extends
                 EPSG[0] = factory;
             }
         }
-        log(Level.WARNING, e);
+        log(e, true);
         return factory;
     }
 
     /**
      * Notifies that a factory is unavailable, but without giving a fallback and without logging.
      * The caller is responsible for logging a warning and to provide its own fallback.
+     *
+     * @return {@code true} on success, or {@code false} if this method did nothing.
      */
-    static void failure(final UnavailableFactoryException e) {
+    static boolean failure(final UnavailableFactoryException e) {
         if (!(e.getCause() instanceof SQLTransientException)) {
             final AuthorityFactory unavailable = e.getUnavailableFactory();
             synchronized (EPSG) {
                 if (unavailable == EPSG[0]) {
                     ALL.reload();
                     EPSG[0] = EPSGFactoryFallback.INSTANCE;
+                    return true;
                 }
             }
         }
+        return false;
     }
 
     /**
      * Logs the given exception at the given level. This method pretends that the logging come from
      * {@link CRS#getAuthorityFactory(String)}, which is the public facade for {@link #EPSG()}.
      */
-    private static void log(final Level level, final Exception e) {
+    private static void log(final Exception e, final boolean isWarning) {
         String message = e.getLocalizedMessage();
         if (message == null) {
             message = e.toString();
         }
-        final LogRecord record = new LogRecord(level, message);
+        final LogRecord record = new LogRecord(isWarning ? Level.WARNING : Level.CONFIG, message);
         record.setLoggerName(Loggers.CRS_FACTORY);
+        if (isWarning) record.setThrown(e);
         Logging.log(CRS.class, "getAuthorityFactory", record);
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -20,6 +20,8 @@ import java.util.Map;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import javax.measure.unit.Unit;
@@ -67,8 +69,10 @@ import org.apache.sis.internal.system.Sy
 import org.apache.sis.internal.system.Modules;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.Exceptions;
 import org.apache.sis.math.MathFunctions;
 import org.apache.sis.measure.Latitude;
 import org.apache.sis.measure.Units;
@@ -516,7 +520,7 @@ public enum CommonCRS {
                         cached = object = factory.createGeographicCRS(String.valueOf(geographic));
                         return object;
                     } catch (FactoryException e) {
-                        failure(this, "geographic", e);
+                        failure(this, "geographic", e, geographic);
                     }
                     /*
                      * All constants defined in this enumeration use the same coordinate system, EPSG:6422.
@@ -572,7 +576,7 @@ public enum CommonCRS {
                             cachedGeo3D = object = factory.createGeographicCRS(String.valueOf(geo3D));
                             return object;
                         } catch (FactoryException e) {
-                            failure(this, "geographic3D", e);
+                            failure(this, "geographic3D", e, geo3D);
                         }
                     }
                     /*
@@ -630,7 +634,7 @@ public enum CommonCRS {
                             cachedGeocentric = object = factory.createGeocentricCRS(String.valueOf(geocentric));
                             return object;
                         } catch (FactoryException e) {
-                            failure(this, "geocentric", e);
+                            failure(this, "geocentric", e, geocentric);
                         }
                     }
                     /*
@@ -686,7 +690,7 @@ public enum CommonCRS {
                         if (factory != null) try {
                             cs = factory.createSphericalCS("6404");
                         } catch (FactoryException e) {
-                            failure(this, "spherical", e);
+                            failure(this, "spherical", e, (short) 6404);
                         }
                         if (cs == null) {
                             cs = (SphericalCS) StandardDefinitions.createCoordinateSystem((short) 6404);
@@ -736,7 +740,7 @@ public enum CommonCRS {
                         cached = object = factory.createGeodeticDatum(String.valueOf(datum));
                         return object;
                     } catch (FactoryException e) {
-                        failure(this, "datum", e);
+                        failure(this, "datum", e, datum);
                     }
                     object = StandardDefinitions.createGeodeticDatum(datum, ellipsoid(), primeMeridian());
                     cached = object;
@@ -780,7 +784,7 @@ public enum CommonCRS {
                             cached = object = factory.createEllipsoid(String.valueOf(ellipsoid));
                             return object;
                         } catch (FactoryException e) {
-                            failure(this, "ellipsoid", e);
+                            failure(this, "ellipsoid", e, ellipsoid);
                         }
                         object = StandardDefinitions.createEllipsoid(ellipsoid);
                     }
@@ -820,7 +824,7 @@ public enum CommonCRS {
                             cached = object = factory.createPrimeMeridian(StandardDefinitions.GREENWICH);
                             return object;
                         } catch (FactoryException e) {
-                            failure(this, "primeMeridian", e);
+                            failure(this, "primeMeridian", e, (short) 8901);
                         }
                         object = StandardDefinitions.primeMeridian();
                     }
@@ -942,7 +946,7 @@ public enum CommonCRS {
                     if (factory != null) try {
                         return factory.createProjectedCRS(String.valueOf(code));
                     } catch (FactoryException e) {
-                        failure(this, "UTM", e);
+                        failure(this, "UTM", e, code);
                     }
                 }
             }
@@ -1192,7 +1196,7 @@ public enum CommonCRS {
                                 cached = object = factory.createVerticalCRS(String.valueOf(crs));
                                 return object;
                             } catch (FactoryException e) {
-                                failure(this, "crs", e);
+                                failure(this, "crs", e, crs);
                             }
                             object = StandardDefinitions.createVerticalCRS(crs, datum());
                         } else {
@@ -1257,7 +1261,7 @@ public enum CommonCRS {
                                 cached = object = factory.createVerticalDatum(String.valueOf(datum));
                                 return object;
                             } catch (FactoryException e) {
-                                failure(this, "datum", e);
+                                failure(this, "datum", e, datum);
                             }
                             object = StandardDefinitions.createVerticalDatum(datum);
                         } else {
@@ -1615,10 +1619,15 @@ public enum CommonCRS {
      * Invoked when a factory failed to create an object.
      * After invoking this method, the caller will fallback on hard-coded values.
      */
-    static void failure(final Object caller, final String method, final FactoryException e) {
-        if (e instanceof UnavailableFactoryException) {
-            AuthorityFactories.failure((UnavailableFactoryException) e);
+    static void failure(final Object caller, final String method, final FactoryException e, final int code) {
+        String message = Errors.format(Errors.Keys.CanNotInstantiate_1, "EPSG:" + code);
+        message = Exceptions.formatChainedMessages(null, message, e);
+        final LogRecord record = new LogRecord(Level.WARNING, message);
+        if (!(e instanceof UnavailableFactoryException) || !AuthorityFactories.failure((UnavailableFactoryException) e)) {
+            // Append the stack trace only if the exception is the the one we expect when the factory is not available.
+            record.setThrown(e);
         }
-        Logging.unexpectedException(Logging.getLogger(Loggers.CRS_FACTORY), caller.getClass(), method, e);
+        record.setLoggerName(Loggers.CRS_FACTORY);
+        Logging.log(caller.getClass(), method, record);
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -748,7 +748,7 @@ public class MultiAuthoritiesFactory ext
                 if (code == null) {
                     message = Errors.format(Errors.Keys.MissingComponentInElement_2, s, "code");
                 } else {
-                    message = Errors.format(Errors.Keys.CanNotCreateObjectOfType_2, type, uri.type);
+                    message = Errors.format(Errors.Keys.CanNotCreateObjectAsInstanceOf_2, type, uri.type);
                 }
                 throw new NoSuchAuthorityCodeException(message, authority, code, s);
             }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -374,28 +374,30 @@ public class EPSGFactory extends Concurr
             if (ac) {
                 connection.setAutoCommit(false);
             }
-            boolean success = false;
             try {
-                if (!"".equals(schema)) {                                               // Schema may be null.
-                    installer.setSchema(schema != null ? schema : Constants.EPSG);
-                    if (catalog != null && !catalog.isEmpty()) {
-                        installer.prependNamespace(catalog);
+                boolean success = false;
+                try {
+                    if (!"".equals(schema)) {                                           // Schema may be null.
+                        installer.setSchema(schema != null ? schema : Constants.EPSG);
+                        if (catalog != null && !catalog.isEmpty()) {
+                            installer.prependNamespace(catalog);
+                        }
                     }
-                }
-                installer.run(scriptProvider, locale);
-                success = true;
-            } finally {
-                if (ac) {
-                    if (success) {
-                        connection.commit();
-                    } else {
-                        connection.rollback();
+                    installer.run(scriptProvider, locale);
+                    success = true;
+                } finally {
+                    if (ac) {
+                        if (success) {
+                            connection.commit();
+                        } else {
+                            connection.rollback();
+                        }
+                        connection.setAutoCommit(true);
                     }
-                    connection.setAutoCommit(true);
-                }
-                if (!success) {
-                    installer.logFailure(locale);
                 }
+            } catch (IOException | SQLException e) {
+                installer.logFailure(locale, e);
+                throw e;
             }
         }
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -34,6 +34,7 @@ import org.apache.sis.internal.metadata.
 import org.apache.sis.internal.metadata.sql.SQLUtilities;
 import org.apache.sis.internal.util.Fallback;
 import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.Exceptions;
 import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.logging.PerformanceLevel;
 import org.apache.sis.setup.InstallationResources;
@@ -284,12 +285,13 @@ final class EPSGInstaller extends Script
      * lets the exception propagate. Another code (for example {@link org.apache.sis.referencing.CRS#forCode(String)})
      * may catch that exception and log another record with the exception message.
      */
-    final void logFailure(final Locale locale) {
+    final void logFailure(final Locale locale, final Exception cause) {
         String message = Messages.getResources(locale).getString(Messages.Keys.CanNotCreateSchema_1, EPSG);
         String status = status(locale);
         if (status != null) {
             message = message + ' ' + status;
         }
+        message = Exceptions.formatChainedMessages(locale, message, cause);
         InstallationScriptProvider.log(new LogRecord(Level.WARNING, message));
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -383,7 +383,7 @@ public abstract class InstallationScript
          */
         @Override
         protected InputStream openStream(final String name) throws IOException {
-            return Files.newInputStream(directory.resolve(name));
+            return (directory != null) ? Files.newInputStream(directory.resolve(name)) : null;
         }
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -510,7 +510,7 @@ next:   for (int i=components.size(); --
             op = new AbstractSingleOperation(properties, sourceCRS, targetCRS, interpolationCRS, method, transform);
         }
         if (!baseType.isInstance(op)) {
-            throw new FactoryException(Errors.format(Errors.Keys.CanNotInstantiate_1, baseType));
+            throw new FactoryException(Errors.format(Errors.Keys.CanNotCreateObjectAsInstanceOf_2, baseType, op.getName()));
         }
         return pool.unique(op);
     }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -22,6 +22,7 @@ import java.util.Locale;
 import java.sql.SQLException;
 import org.apache.sis.internal.util.LocalizedException;
 
+import org.apache.sis.util.resources.Vocabulary;
 import static org.apache.sis.util.CharSequences.trimWhitespaces;
 
 
@@ -30,7 +31,7 @@ import static org.apache.sis.util.CharSe
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  */
 public final class Exceptions extends Static {
@@ -109,8 +110,8 @@ public final class Exceptions extends St
      * Returns a string which contain the given message on the first line, followed by the
      * {@linkplain Throwable#getLocalizedMessage() localized message} of the given exception
      * on the next line. If the exception has a {@linkplain Throwable#getCause() causes}, then
-     * the localized message of the cause is formatted on the next line and the process is
-     * repeated for the whole cause chain, omitting duplicated messages.
+     * the class name and the localized message of the cause are formatted on the next line
+     * and the process is repeated for the whole cause chain, omitting duplicated messages.
      *
      * <p>{@link SQLException} is handled especially in order to process the
      * {@linkplain SQLException#getNextException() next exception} instead than the cause.</p>
@@ -124,16 +125,15 @@ public final class Exceptions extends St
      *         and no exception provide a message.
      */
     public static String formatChainedMessages(final Locale locale, String header, Throwable cause) {
-        List<String> previousLines = null;
-        String lineSeparator = null;
+        final List<String> previousLines = new ArrayList<>();
+        final String lineSeparator = System.lineSeparator();
         StringBuilder buffer = null;
+        Vocabulary resources = null;
         while (cause != null) {
             final String message = trimWhitespaces(getLocalizedMessage(cause, locale));
             if (message != null && !message.isEmpty()) {
                 if (buffer == null) {
                     buffer = new StringBuilder(128);
-                    previousLines = new ArrayList<>(4);
-                    lineSeparator = System.lineSeparator();
                     header = trimWhitespaces(header);
                     if (header != null && !header.isEmpty()) {
                         buffer.append(header);
@@ -144,6 +144,10 @@ public final class Exceptions extends St
                     previousLines.add(message);
                     if (buffer.length() != 0) {
                         buffer.append(lineSeparator);
+                        if (resources == null) {
+                            resources = Vocabulary.getResources(locale);
+                        }
+                        buffer.append(resources.getString(Vocabulary.Keys.CausedBy_1, cause.getClass())).append(": ");
                     }
                     buffer.append(message);
                 }
@@ -168,8 +172,7 @@ public final class Exceptions extends St
      */
     private static boolean contains(final List<String> previousLines, final String message) {
         for (int i=previousLines.size(); --i>=0;) {
-            final int p = previousLines.get(i).indexOf(message);
-            if (p >= 0) {
+            if (previousLines.get(i).contains(message)) {
                 return true;
             }
         }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -86,7 +86,7 @@ import org.apache.sis.util.Debug;
  *     #
  *     #  source: If set, writes the source logger name or the source class name.
  *     #          Valid argument values are "none", "logger:short", "logger:long",
- *     #          "class:short" and "class:long".
+ *     #          "class:short", "class:long" and "class.method".
  *     ###########################################################################
  *     org.apache.sis.util.logging.MonolineFormatter.time = HH:mm:ss.SSS
  *     org.apache.sis.util.logging.MonolineFormatter.source = class:short
@@ -120,16 +120,18 @@ public class MonolineFormatter extends F
     /** Format the source logger only.         */ private static final int LOGGER_LONG  = 2;
     /** Format the class name without package. */ private static final int CLASS_SHORT  = 3;
     /** Format the fully qualified class name. */ private static final int CLASS_LONG   = 4;
+    /** Format the class name and method name. */ private static final int METHOD       = 5;
 
     /**
      * The label to use in the {@code logging.properties} for setting the source format.
      */
-    private static final String[] FORMAT_LABELS = new String[5];
+    private static final String[] FORMAT_LABELS = new String[6];
     static {
         FORMAT_LABELS[LOGGER_SHORT] = "logger:short";
         FORMAT_LABELS[LOGGER_LONG ] = "logger:long";
         FORMAT_LABELS[ CLASS_SHORT] = "class:short";
         FORMAT_LABELS[ CLASS_LONG ] = "class:long";
+        FORMAT_LABELS[METHOD      ] = "class.method";
     }
 
     /**
@@ -234,7 +236,7 @@ public class MonolineFormatter extends F
 
     /**
      * One of the following constants: {@link #NO_SOURCE}, {@link #LOGGER_SHORT},
-     * {@link #LOGGER_LONG}, {@link #CLASS_SHORT} or {@link #CLASS_LONG}.
+     * {@link #LOGGER_LONG}, {@link #CLASS_SHORT}, {@link #CLASS_LONG} or {@link #METHOD}.
      */
     private int sourceFormat = NO_SOURCE;
 
@@ -373,7 +375,7 @@ loop:   for (int i=0; ; i++) {
      *        or {@code null} if none.
      */
     public void setHeader(String header) {
-        if (header == null) { // See comment in getHeader().
+        if (header == null) {                           // See comment in getHeader().
             header = "";
         }
         synchronized (buffer) {
@@ -452,6 +454,8 @@ loop:   for (int i=0; ; i++) {
      *   <li>{@code "logger:long"}  for the {@linkplain LogRecord#getLoggerName() logger name}</li>
      *   <li>{@code "class:short"}  for the source class name without the package part.</li>
      *   <li>{@code "logger:short"} for the logger name without the package part.</li>
+     *   <li>{@code "class.method"} for the short class name followed by the
+     *       {@linkplain LogRecord#getSourceMethodName() source method name}</li>
      * </ul>
      *
      * The source class name usually contains the logger name since (by convention) logger
@@ -603,7 +607,7 @@ loop:   for (int i=0; ; i++) {
         }
         int i = Arrays.binarySearch(colorLevels, level.intValue());
         if (i < 0) {
-            i = Math.max((~i)-1, 0);  // Really tild, not minus sign.
+            i = Math.max((~i)-1, 0);                    // Really tild, not minus sign.
         }
         return colorSequences[i];
     }
@@ -658,12 +662,14 @@ loop:   for (int i=0; ; i++) {
             switch (sourceFormat) {
                 case LOGGER_SHORT: // Fall through
                 case LOGGER_LONG:  source = record.getLoggerName(); break;
+                case METHOD:       // Fall through
                 case CLASS_SHORT:  // Fall through
                 case CLASS_LONG:   source = record.getSourceClassName(); break;
                 default:           source = null; break;
             }
             if (source != null) {
                 switch (sourceFormat) {
+                    case METHOD:       // Fall through
                     case LOGGER_SHORT: // Fall through
                     case CLASS_SHORT: {
                         // Works even if there is no '.' since we get -1 as index.
@@ -671,6 +677,9 @@ loop:   for (int i=0; ; i++) {
                         break;
                     }
                 }
+                if (sourceFormat == METHOD) {
+                    source = source + '.' + record.getSourceMethodName();
+                }
                 if (colors && emphase) {
                     buffer.append(X364.BOLD.sequence());
                 }
@@ -710,7 +719,7 @@ loop:   for (int i=0; ; i++) {
                 }
                 if (exception != null) {
                     if (message != null) {
-                        writer.append("\nCaused by: "); // LineAppender will replace '\n' by the system EOL.
+                        writer.append("\nCaused by: ");     // LineAppender will replace '\n' by the system EOL.
                     }
                     if (level.intValue() >= LEVEL_THRESHOLD.intValue()) {
                         exception.printStackTrace(printer);
@@ -879,7 +888,7 @@ loop:   for (int i=0; ; i++) {
             if (con) {
                 writer.append(" ...");
             }
-            writer.append('\n'); // LineAppender will replace '\n' by the system EOL.
+            writer.append('\n');                    // LineAppender will replace '\n' by the system EOL.
         }
     }
 
@@ -999,7 +1008,7 @@ loop:   for (int i=0; ; i++) {
             }
             final Handler handler = new ConsoleHandler();
             if (level != null) {
-                handler.setLevel(level); // Shall be before MonolineFormatter creation.
+                handler.setLevel(level);                    // Shall be before MonolineFormatter creation.
             }
             monoline = new MonolineFormatter(handler);
             handler.setFormatter(monoline);

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -121,12 +121,12 @@ public final class Errors extends Indexe
         public static final short CanNotConvertValue_2 = 4;
 
         /**
-         * Can not create an object of type “{1}” as an instance of ‘{0}’.
+         * Can not create an object “{1}” as an instance of class ‘{0}’.
          */
-        public static final short CanNotCreateObjectOfType_2 = 215;
+        public static final short CanNotCreateObjectAsInstanceOf_2 = 215;
 
         /**
-         * Can not instantiate an object of type ‘{0}’.
+         * Can not instantiate “{0}”.
          */
         public static final short CanNotInstantiate_1 = 5;
 

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Fri Mar 18 22:40:14 2016
@@ -35,8 +35,8 @@ CanNotConvertFromType_2           = Can
 CanNotConvertValue_2              = Can not convert value \u201c{0}\u201d to type \u2018{1}\u2019.
 CanNotCompute_1                   = Can not compute \u201c{0}\u201d.
 CanNotComputeDerivative           = Can not compute the derivative.
-CanNotCreateObjectOfType_2        = Can not create an object of type \u201c{1}\u201d as an instance of \u2018{0}\u2019.
-CanNotInstantiate_1               = Can not instantiate an object of type \u2018{0}\u2019.
+CanNotCreateObjectAsInstanceOf_2  = Can not create an object \u201c{1}\u201d as an instance of class \u2018{0}\u2019.
+CanNotInstantiate_1               = Can not instantiate \u201c{0}\u201d.
 CanNotMapAxisToDirection_2        = Can not map an axis from \u201c{0}\u201d to direction \u201c{1}\u201d.
 CanNotOpen_1                      = Can not open \u201c{0}\u201d.
 CanNotParseFile_2                 = Can not parse \u201c{1}\u201d as a file in the {0} format.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Fri Mar 18 22:40:14 2016
@@ -32,8 +32,8 @@ CanNotConvertFromType_2           = Ne p
 CanNotConvertValue_2              = La valeur \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre convertie vers le type \u2018{1}\u2019.
 CanNotCompute_1                   = Ne peut pas calculer \u00ab\u202f{0}\u202f\u00bb.
 CanNotComputeDerivative           = La d\u00e9riv\u00e9 ne peut pas \u00eatre calcul\u00e9e.
-CanNotCreateObjectOfType_2        = Ne peut pas cr\u00e9er un objet de type \u00ab\u202f{1}\u202f\u00bb comme une instance de \u2018{0}\u2019.
-CanNotInstantiate_1               = Ne peut pas cr\u00e9er un objet de type \u2018{0}\u2019.
+CanNotCreateObjectAsInstanceOf_2  = Ne peut pas cr\u00e9er un objet de type \u00ab\u202f{1}\u202f\u00bb comme une instance de la classe \u2018{0}\u2019.
+CanNotInstantiate_1               = Ne peut pas cr\u00e9er \u00ab\u202f{0}\u202f\u00bb.
 CanNotMapAxisToDirection_2        = Aucun axe de \u00ab\u202f{0}\u202f\u00bb n\u2019a pu \u00eatre associ\u00e9 \u00e0 la direction \u00ab\u202f{1}\u202f\u00bb.
 CanNotOpen_1                      = Ne peut pas ouvrir \u00ab\u202f{0}\u202f\u00bb.
 CanNotParseFile_2                 = Ne peut pas lire \u00ab\u202f{1}\u202f\u00bb comme un fichier au format {0}.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -101,6 +101,11 @@ public final class Vocabulary extends In
         public static final short Cardinality = 76;
 
         /**
+         * Caused by {0}
+         */
+        public static final short CausedBy_1 = 107;
+
+        /**
          * Character encoding
          */
         public static final short CharacterEncoding = 6;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] Fri Mar 18 22:40:14 2016
@@ -23,6 +23,7 @@ Attributes              = Attributes
 AxisChanges             = Axis changes
 BarometricAltitude      = Barometric altitude
 Cardinality             = Cardinality
+CausedBy_1              = Caused by {0}
 CharacterEncoding       = Character encoding
 Characteristics         = Characteristics
 Classpath               = Classpath

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] Fri Mar 18 22:40:14 2016
@@ -30,6 +30,7 @@ Attributes              = Attributs
 AxisChanges             = Changements d\u2019axes
 BarometricAltitude      = Altitude barom\u00e9trique
 Cardinality             = Cardinalit\u00e9
+CausedBy_1              = Caus\u00e9e par {0}
 CharacterEncoding       = Encodage des caract\u00e8res
 Characteristics         = Caract\u00e9ristiques
 Classpath               = Chemin de classes

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -19,12 +19,14 @@ package org.apache.sis.test;
 import java.util.logging.Logger;
 import java.util.logging.Handler;
 import java.util.logging.ConsoleHandler;
+import java.util.logging.LogManager;
 import java.io.Console;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import org.apache.sis.util.logging.Logging;
+import org.apache.sis.util.logging.MonolineFormatter;
 import org.junit.runner.RunWith;
 
 
@@ -132,6 +134,17 @@ public abstract strictfp class TestCase
     static final Logger LOGGER = Logger.getLogger("org.apache.sis");
 
     /**
+     * Initializes {@link MonolineFormatter} if it has been specified in the {@code logging.properties}
+     * configuration file.
+     */
+    static {
+        final LogManager manager = LogManager.getLogManager();
+        if (MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName() + ".formatter"))) {
+            MonolineFormatter.install();
+        }
+    }
+
+    /**
      * Sets the encoding of the console logging handler, if an encoding has been specified.
      * Note that we look specifically for {@link ConsoleHandler}; we do not generalize to
      * {@link StreamHandler} because the log files may not be intended for being show in

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -17,6 +17,7 @@
 package org.apache.sis.util;
 
 import java.util.Locale;
+import java.io.IOException;
 import java.io.FileNotFoundException;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -29,7 +30,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  */
 public final strictfp class ExceptionsTest extends TestCase {
@@ -40,7 +41,7 @@ public final strictfp class ExceptionsTe
     public void testFormatChainedMessages() {
         final String lineSeparator = System.lineSeparator();
         final FileNotFoundException cause = new FileNotFoundException("MisingFile.txt");
-        cause.initCause(new Exception("Disk is not mounted."));
+        cause.initCause(new IOException("Disk is not mounted."));
         final Exception e = new Exception("Can not find “MisingFile.txt”.", cause);
         /*
          * The actual sequence of messages (with their cause is):
@@ -51,15 +52,17 @@ public final strictfp class ExceptionsTe
          *
          * But the second line shall be omitted because it duplicates the first line.
          */
+        String message = Exceptions.formatChainedMessages(Locale.ENGLISH, null, e);
         assertEquals("Can not find “MisingFile.txt”." + lineSeparator +
-                     "Disk is not mounted.",
-                     Exceptions.formatChainedMessages(Locale.ENGLISH, null, e));
+                     "Caused by IOException: Disk is not mounted.",
+                     message);
         /*
          * Test again with a header.
          */
+        message = Exceptions.formatChainedMessages(Locale.ENGLISH, "Error while creating the data store.", e);
         assertEquals("Error while creating the data store." + lineSeparator +
-                     "Can not find “MisingFile.txt”." + lineSeparator +
-                     "Disk is not mounted.",
-                     Exceptions.formatChainedMessages(Locale.ENGLISH, "Error while creating the data store.", e));
+                     "Caused by Exception: Can not find “MisingFile.txt”." + lineSeparator +
+                     "Caused by IOException: Disk is not mounted.",
+                     message);
     }
 }

Modified: sis/branches/JDK8/src/main/config/logging.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/src/main/config/logging.properties?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/src/main/config/logging.properties [UTF-8] (original)
+++ sis/branches/JDK8/src/main/config/logging.properties [UTF-8] Fri Mar 18 22:40:14 2016
@@ -25,3 +25,8 @@ org.apache.sis.level= FINE
 # Set the message that are printed on the console to FINE and above.
 # FINE provides debugging information normally hidden in production.
 java.util.logging.ConsoleHandler.level = FINE
+
+# The MonolineFormatter is specific to Apache SIS and optional.
+# See its javadoc for information on configuration options.
+java.util.logging.ConsoleHandler.formatter = org.apache.sis.util.logging.MonolineFormatter
+org.apache.sis.util.logging.MonolineFormatter.source = class.method

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -28,6 +28,7 @@ import java.nio.FloatBuffer;
 import java.nio.DoubleBuffer;
 import java.nio.channels.ReadableByteChannel;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.Debug;
 
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
@@ -190,7 +191,7 @@ public class ChannelDataInput extends Ch
     /**
      * Returns the "end of file" error message, for {@link EOFException} creations.
      */
-    final String eof() {
+    private String eof() {
         return Errors.format(Errors.Keys.UnexpectedEndOfFile_1, filename);
     }
 
@@ -527,11 +528,12 @@ public class ChannelDataInput extends Ch
         }
 
         /**
-         * Returns the enclosing data input.
+         * Returns a file identifier for error messages or debugging purpose.
          */
+        @Debug
         @Override
-        public final ChannelDataInput input() {
-            return ChannelDataInput.this;
+        public final String filename() {
+            return filename;
         }
 
         /**

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DataTransfer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DataTransfer.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DataTransfer.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DataTransfer.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -18,6 +18,7 @@ package org.apache.sis.internal.storage;
 
 import java.io.IOException;
 import java.nio.Buffer;
+import org.apache.sis.util.Debug;
 
 
 /**
@@ -31,9 +32,10 @@ import java.nio.Buffer;
  */
 interface DataTransfer {
     /**
-     * Returns the enclosing data input.
+     * Returns a file identifier for error messages or debugging purpose.
      */
-    ChannelDataInput input();
+    @Debug
+    String filename();
 
     /**
      * Returns the size of the Java primitive type which is the element of the array.

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/HyperRectangleReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/HyperRectangleReader.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/HyperRectangleReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/HyperRectangleReader.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -22,6 +22,7 @@ import java.io.IOException;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.util.Debug;
 
 
 /**
@@ -83,22 +84,23 @@ public final class HyperRectangleReader
      * Creates a new reader for the data in an existing buffer.
      * The data will be read from the current buffer position to the buffer limit.
      *
-     * @param name   The data source name, for information purpose only.
+     * @param filename A data source name, for error messages or debugging purpose.
      * @param data A buffer containing the data to read.
      * @throws IOException should never happen.
      */
-    public HyperRectangleReader(final String name, final Buffer data) throws IOException {
-        reader = new MemoryDataTransfer(name, data).reader();
+    public HyperRectangleReader(final String filename, final Buffer data) throws IOException {
+        reader = new MemoryDataTransfer(filename, data).reader();
         origin = 0;
     }
 
     /**
-     * Returns the data input specified at construction time.
+     * Returns a file identifier for error messages or debugging purpose.
      *
-     * @return The input channel together with the buffer.
+     * @return the file identifier.
      */
-    public final ChannelDataInput input() {
-        return reader.input();
+    @Debug
+    public String filename() {
+        return reader.filename();
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryDataTransfer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryDataTransfer.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryDataTransfer.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryDataTransfer.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -79,18 +79,14 @@ final class MemoryDataTransfer implement
      */
     @Override
     public void seek(long position) throws IOException {
-        assert input().bufferOffset == 0;
-        if (position < 0) {
-            throw new IOException(Errors.format(Errors.Keys.NegativeArgument_2, "position", position));
-        }
         final int dataSizeShift = dataSizeShift();
-        if ((position & ((1 << dataSizeShift) - 1)) != 0) {
+        if (position < 0 || (position & ((1 << dataSizeShift) - 1)) != 0) {
             throw new IOException(Errors.format(Errors.Keys.IllegalArgumentValue_2, "position", position));
         }
         position >>>= dataSizeShift;
         final Buffer data = view();
         if (position > data.limit()) {
-            throw new EOFException(input().eof());
+            throw new EOFException(Errors.format(Errors.Keys.UnexpectedEndOfFile_1, filename()));
         }
         data.position((int) position);
     }
@@ -98,13 +94,13 @@ final class MemoryDataTransfer implement
     /**
      * Delegates to the actual implementation.
      */
-    @Override public ChannelDataInput input()                     {return reader.input();}
-    @Override public int              dataSizeShift()             {return reader.dataSizeShift();}
-    @Override public Object           dataArray()                 {return reader.dataArray();}
-    @Override public Buffer           view()                      {return reader.view();}
-    @Override public Buffer           createView()                {return reader.createView();}
-    @Override public void             createDataArray(int length) {reader.createDataArray(length);}
-    @Override public void             setDest(Object array)       {reader.setDest(array);}
+    @Override public String filename()                  {return filename();}
+    @Override public int    dataSizeShift()             {return reader.dataSizeShift();}
+    @Override public Object dataArray()                 {return reader.dataArray();}
+    @Override public Buffer view()                      {return reader.view();}
+    @Override public Buffer createView()                {return reader.createView();}
+    @Override public void   createDataArray(int length) {reader.createDataArray(length);}
+    @Override public void   setDest(Object array)       {reader.setDest(array);}
 
     /**
      * Reads {@code length} values from the buffer and stores them into the array known to subclass,

Modified: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/HyperRectangleReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/HyperRectangleReaderTest.java?rev=1735699&r1=1735698&r2=1735699&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/HyperRectangleReaderTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/HyperRectangleReaderTest.java [UTF-8] Fri Mar 18 22:40:14 2016
@@ -22,8 +22,6 @@ import java.nio.ByteOrder;
 import java.nio.ByteBuffer;
 import java.nio.ShortBuffer;
 import java.io.IOException;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.SeekableByteChannel;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.test.DependsOnMethod;
@@ -168,21 +166,6 @@ public final strictfp class HyperRectang
     }
 
     /**
-     * Asserts that the reader used a channel and has read at least some bytes.
-     *
-     * @param expected {@code true} if the reader should have used a channel,
-     *        or {@code false} if it should have used in-memory data instead.
-     */
-    private void assertUsedChannel(final boolean expected) throws IOException {
-        final ChannelDataInput input = reader.input();
-        final ReadableByteChannel channel = input.channel;
-        assertEquals("(channel instanceof InMemoryInput)", !expected, channel instanceof MemoryDataTransfer);
-        if (expected) {
-            assertTrue(((SeekableByteChannel) channel).position() > input.channelOffset);
-        }
-    }
-
-    /**
      * Tests reading a random part of the hyper-cube without sub-sampling.
      *
      * @throws IOException should never happen.
@@ -193,7 +176,6 @@ public final strictfp class HyperRectang
         initialize(TestUtilities.createRandomNumberGenerator(), true);
         Arrays.fill(subsampling, 0, subsampling.length, 1);
         verifyRegionRead();
-        assertUsedChannel(true);
     }
 
     /**
@@ -208,7 +190,6 @@ public final strictfp class HyperRectang
         System.arraycopy(size, 0, upper, 0, size.length);
         Arrays.fill(lower, 0, lower.length, 0);
         verifyRegionRead();
-        assertUsedChannel(true);
     }
 
     /**
@@ -222,7 +203,6 @@ public final strictfp class HyperRectang
     public void testRandom() throws IOException, DataStoreException {
         initialize(TestUtilities.createRandomNumberGenerator(), true);
         verifyRegionRead();
-        assertUsedChannel(true);
     }
 
     /**
@@ -236,6 +216,5 @@ public final strictfp class HyperRectang
     public void testMemoryTransfer() throws IOException, DataStoreException {
         initialize(TestUtilities.createRandomNumberGenerator(), false);
         verifyRegionRead();
-        assertUsedChannel(false);
     }
 }



Mime
View raw message