sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1762629 [15/15] - in /sis/trunk: ./ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-console/src/test/java/org/apache/sis/console/ application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ application...
Date Wed, 28 Sep 2016 09:59:48 GMT
Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -17,7 +17,7 @@
 package org.apache.sis.internal.storage;
 
 import java.util.Set;
-import java.util.List;
+import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Collections;
 import java.util.Arrays;
@@ -41,9 +41,14 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.internal.system.Modules;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk7.Files;
-import org.apache.sis.internal.jdk7.StandardCharsets;
-import org.apache.sis.internal.jdk7.StandardOpenOption;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
+import java.nio.file.FileSystemNotFoundException;
+import java.nio.file.OpenOption;
+import java.nio.file.StandardOpenOption;
+import java.nio.charset.StandardCharsets;
 
 
 /**
@@ -65,7 +70,7 @@ public final class IOUtilities extends S
     /**
      * Options to be rejected by {@link #open(Object, String, OpenOption[])} for safety reasons.
      */
-    private static final List<String> ILLEGAL_OPTIONS = Arrays.asList( // EnumSet of StandardOpenOption on JDK7 branch
+    private static final Set<StandardOpenOption> ILLEGAL_OPTIONS = EnumSet.of(
             StandardOpenOption.APPEND, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.DELETE_ON_CLOSE);
 
     /**
@@ -108,6 +113,8 @@ public final class IOUtilities extends S
         final String name;
         if (path instanceof File) {
             name = ((File) path).getName();
+        } else if (path instanceof Path) {
+            name = ((Path) path).getFileName().toString();
         } else {
             char separator = '/';
             if (path instanceof URL) {
@@ -146,7 +153,7 @@ public final class IOUtilities extends S
     public static String toString(final Object path) {
         // For the following types, the string that we want can be obtained only by toString(),
         // or the class is final so we know that the toString(à behavior can not be changed.
-        if (path instanceof CharSequence || path instanceof URL || path instanceof URI) {
+        if (path instanceof CharSequence || path instanceof Path || path instanceof URL || path instanceof URI) {
             return path.toString();
         }
         // While toString() would work too on the default implementation, the following
@@ -302,6 +309,51 @@ public final class IOUtilities extends S
     }
 
     /**
+     * Converts a {@link URL} to a {@link Path}. This is equivalent to a call to the standard
+     * {@link URL#toURI()} method followed by a call to the {@link Paths#get(URI)} static method,
+     * except for the following functionalities:
+     *
+     * <ul>
+     *   <li>Optionally decodes the {@code "%XX"} sequences, where {@code "XX"} is a number.</li>
+     *   <li>Converts various exceptions into subclasses of {@link IOException}.</li>
+     * </ul>
+     *
+     * @param  url The URL to convert, or {@code null}.
+     * @param  encoding If the URL is encoded in a {@code application/x-www-form-urlencoded}
+     *         MIME format, the character encoding (normally {@code "UTF-8"}). If the URL is
+     *         not encoded, then {@code null}.
+     * @return The path for the given URL, or {@code null} if the given URL was null.
+     * @throws IOException if the URL can not be converted to a path.
+     *
+     * @see Paths#get(URI)
+     */
+    public static Path toPath(final URL url, final String encoding) throws IOException {
+        if (url == null) {
+            return null;
+        }
+        final URI uri = toURI(url, encoding);
+        try {
+            return Paths.get(uri);
+        } catch (IllegalArgumentException | FileSystemNotFoundException cause) {
+            final String message = Exceptions.formatChainedMessages(null,
+                    Errors.format(Errors.Keys.IllegalArgumentValue_2, "URL", url), cause);
+            /*
+             * If the exception is IllegalArgumentException, then the URI scheme has been recognized
+             * but the URI syntax is illegal for that file system. So we can consider that the URL is
+             * malformed in regard to the rules of that particular file system.
+             */
+            final IOException e;
+            if (cause instanceof IllegalArgumentException) {
+                e = new MalformedURLException(message);
+                e.initCause(cause);
+            } else {
+                e = new IOException(message, cause);
+            }
+            throw e;
+        }
+    }
+
+    /**
      * Parses the following path as a {@link File} if possible, or a {@link URL} otherwise.
      * In the special case where the given {@code path} is a URL using the {@code "file"} protocol,
      * the URL is converted to a {@link File} object using the given {@code encoding} for decoding
@@ -384,15 +436,15 @@ public final class IOUtilities extends S
      * @return The channel for the given input, or {@code null} if the given input is of unknown type.
      * @throws IOException If an error occurred while opening the given file.
      */
-    public static ReadableByteChannel open(Object input, final String encoding, Object... options) throws IOException {
+    public static ReadableByteChannel open(Object input, final String encoding, OpenOption... options) throws IOException {
         /*
          * Unconditionally verify the options, even if we may not use them.
          */
-        final Set<Object> optionSet;
+        final Set<OpenOption> optionSet;
         if (options == null || options.length == 0) {
-            optionSet = Collections.<Object>singleton(StandardOpenOption.READ);
+            optionSet = Collections.<OpenOption>singleton(StandardOpenOption.READ);
         } else {
-            optionSet = new HashSet<Object>(Arrays.asList(options));
+            optionSet = new HashSet<>(Arrays.asList(options));
             optionSet.add(StandardOpenOption.READ);
             if (optionSet.removeAll(ILLEGAL_OPTIONS)) {
                 throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentValue_2,
@@ -414,15 +466,13 @@ public final class IOUtilities extends S
             }
             return Channels.newChannel((InputStream) input);
         }
-        // NOTE: Many comments below this point actually apply to the JDK7 branch.
-        //       We keep them here for making easier the synchonization between the branches.
         /*
          * In the following cases, we will try hard to convert to Path objects before to fallback
          * on File, URL or URI, because only Path instances allow us to use the given OpenOptions.
          */
         if (input instanceof URL) {
             try {
-                input = toFile((URL) input, encoding);
+                input = toPath((URL) input, encoding);
             } catch (IOException e) {
                 // This is normal if the URL uses HTTP or FTP protocol for instance.
                 // Log the exception at FINE level without stack trace. We will open
@@ -441,9 +491,14 @@ public final class IOUtilities extends S
                 // so we are better to check now and provide a more appropriate exception for this method.
                 throw new IOException(Errors.format(Errors.Keys.MissingSchemeInURI));
             } else try {
-                input = new File(uri);
-            } catch (IllegalArgumentException e) {
-                input = uri.toURL();
+                input = Paths.get(uri);
+            } catch (IllegalArgumentException | FileSystemNotFoundException e) {
+                try {
+                    input = uri.toURL();
+                } catch (MalformedURLException ioe) {
+                    ioe.addSuppressed(e);
+                    throw ioe;
+                }
                 // We have been able to convert to URL, but the given OpenOptions may not be used.
                 // Log the exception at FINE level without stack trace, because the exception is
                 // probably a normal behavior in this context.
@@ -453,6 +508,31 @@ public final class IOUtilities extends S
             if (input instanceof CharSequence) { // Needs to be before the check for File or URL.
                 input = toFileOrURL(input.toString(), encoding);
             }
+            /*
+             * If the input is a File or a CharSequence that we have been able to convert to a File,
+             * try to convert to a Path in order to be able to use the OpenOptions. Only if we fail
+             * to convert to a Path (which is unlikely), we will use directly the File.
+             */
+            if (input instanceof File) {
+                try {
+                    input = ((File) input).toPath();
+                } catch (InvalidPathException e) {
+                    // Unlikely to happen. But if it happens anyway, try to open the channel in a
+                    // way less surprising for the user (closer to the object he has specified).
+                    final ReadableByteChannel channel;
+                    try {
+                        channel = new FileInputStream((File) input).getChannel();
+                    } catch (IOException ioe) {
+                        ioe.addSuppressed(e);
+                        throw ioe;
+                    }
+                    // We have been able to create a channel, maybe not with the given OpenOptions.
+                    // But the exception was nevertheless unexpected, so log its stack trace in order
+                    // to allow the developer to check if there is something wrong.
+                    Logging.unexpectedException(Logging.getLogger(Modules.STORAGE), IOUtilities.class, "open", e);
+                    return channel;
+                }
+            }
         }
         /*
          * One last check for URL. The URL may be either the given input if we have not been able
@@ -462,8 +542,8 @@ public final class IOUtilities extends S
         if (input instanceof URL) {
             return Channels.newChannel(((URL) input).openStream());
         }
-        if (input instanceof File) {
-            return Files.newByteChannel((File) input, optionSet);
+        if (input instanceof Path) {
+            return Files.newByteChannel((Path) input, optionSet);
         }
         return null;
     }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -48,7 +48,6 @@ import org.apache.sis.util.iso.Types;
 import static org.apache.sis.internal.util.StandardDateFormat.MILLISECONDS_PER_DAY;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk7.JDK7;
 import org.apache.sis.internal.jdk8.LocalDate;
 import org.apache.sis.metadata.iso.citation.DefaultResponsibleParty;
 
@@ -428,7 +427,7 @@ public class MetadataBuilder {
         if (p.contains(a)) {
             return previous;
         }
-        return Types.toInternationalString(p + JDK7.lineSeparator() + a);
+        return Types.toInternationalString(p + System.lineSeparator() + a);
     }
 
     /**

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -62,6 +62,7 @@ import org.apache.sis.util.resources.Ind
 import org.apache.sis.internal.jdk8.Instant;
 import org.apache.sis.feature.AbstractFeature;
 import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.internal.jdk8.DateTimeException;
 import org.apache.sis.setup.OptionKey;
 
 
@@ -188,7 +189,7 @@ public final class Store extends DataSto
         DefaultFeatureType featureType = null;
         Foliation foliation = null;
         try {
-            final List<String> elements = new ArrayList<String>();
+            final List<String> elements = new ArrayList<>();
             source.mark(1024);
             String line;
             while ((line = source.readLine()) != null) {
@@ -199,15 +200,15 @@ public final class Store extends DataSto
                 if (c != METADATA) break;
                 split(line, elements);
                 final String keyword = elements.get(0);
-                /*switch (k)*/ {
-                    final String k = keyword.toLowerCase(Locale.US);
-                    if (k.equals("@stboundedby")) {
+                switch (keyword.toLowerCase(Locale.US)) {
+                    case "@stboundedby": {
                         if (envelope != null) {
                             throw new DataStoreContentException(duplicated("@stboundedby"));
                         }
                         envelope = parseEnvelope(elements);
+                        break;
                     }
-                    else if (k.equals("@columns")) {
+                    case "@columns": {
                         if (featureType != null) {
                             throw new DataStoreContentException(duplicated("@columns"));
                         }
@@ -215,32 +216,35 @@ public final class Store extends DataSto
                         if (foliation == null) {
                             foliation = Foliation.TIME;
                         }
+                        break;
                     }
-                    else if (k.equals("@foliation")) {
+                    case "@foliation": {
                         if (foliation != null) {
                             throw new DataStoreContentException(duplicated("@foliation"));
                         }
                         foliation = parseFoliation(elements);
+                        break;
                     }
-                    else {
+                    default: {
                         final LogRecord record = errors().getLogRecord(Level.WARNING, Errors.Keys.UnknownKeyword_1, keyword);
                         record.setSourceClassName(Store.class.getName());
                         record.setSourceMethodName("parseHeader");
                         listeners.warning(record);
+                        break;
                     }
                 }
                 elements.clear();
                 source.mark(1024);
             }
             source.reset();
-        } catch (Exception e) {     // This is a multi-catch on the JDK7 branch.
+        } catch (IOException | FactoryException | IllegalArgumentException | DateTimeException e) {
             throw new DataStoreException(errors().getString(Errors.Keys.CanNotParseFile_2, "CSV", name), e);
         }
         this.encoding    = connector.getOption(OptionKey.ENCODING);
         this.envelope    = envelope;
         this.featureType = featureType;
         this.foliation   = foliation;
-        this.features    = new ArrayList<AbstractFeature>();
+        this.features    = new ArrayList<>();
     }
 
     /**
@@ -268,21 +272,15 @@ public final class Store extends DataSto
         GeneralEnvelope envelope      = null;
         switch (elements.size()) {
             default:final String unit = elements.get(7);
-                    /*switch (k)*/ {
-                        final String k = unit.toLowerCase(Locale.US);
-                        if (k.isEmpty() || k.equals("sec") || k.equals("second")) {
-                            /* Already SI.SECOND. */
-                        } else if (k.equals("minute")) {
-                            timeUnit = NonSI.MINUTE;
-                        } else if (k.equals("hour")) {
-                            timeUnit = NonSI.HOUR;
-                        } else if (k.equals("day")) {
-                            timeUnit = NonSI.DAY;
-                        } else if (k.equals("absolute")) {
-                            isTimeAbsolute = true;
-                        } else {
-                            throw new DataStoreContentException(errors().getString(Errors.Keys.UnknownUnit_1, unit));
-                        }
+                    switch (unit.toLowerCase(Locale.US)) {
+                        case "":
+                        case "sec":
+                        case "second":   /* Already SI.SECOND. */ break;
+                        case "minute":   timeUnit = NonSI.MINUTE; break;
+                        case "hour":     timeUnit = NonSI.HOUR;   break;
+                        case "day":      timeUnit = NonSI.DAY;    break;
+                        case "absolute": isTimeAbsolute = true;   break;
+                        default: throw new DataStoreContentException(errors().getString(Errors.Keys.UnknownUnit_1, unit));
                     }
                     // Fall through
             case 7: endTime     = Instant      .parse(       elements.get(6));
@@ -290,16 +288,12 @@ public final class Store extends DataSto
             case 5: upperCorner = CharSequences.parseDoubles(elements.get(4), ORDINATE_SEPARATOR);
             case 4: lowerCorner = CharSequences.parseDoubles(elements.get(3), ORDINATE_SEPARATOR);
             case 3: final String dimension = elements.get(2);
-                    /* switch (k)*/ {
-                        final String k = dimension.toUpperCase(Locale.US);
-                        if (k.isEmpty() || k.equals("2D")) {
-                            // Default to 2D.
-                        } else if (k.equals("3D")) {
-                            is3D = true;
-                        } else {
-                            throw new DataStoreContentException(errors().getString(
+                    switch (dimension.toUpperCase(Locale.US)) {
+                        case "":   // Default to 2D.
+                        case "2D": break;
+                        case "3D": is3D = true; break;
+                        default: throw new DataStoreContentException(errors().getString(
                                         Errors.Keys.IllegalCoordinateSystem_1, dimension));
-                        }
                     }
                     // Fall through
             case 2: crs = CRS.forCode(elements.get(1));
@@ -378,7 +372,7 @@ public final class Store extends DataSto
      */
     private DefaultFeatureType parseFeatureType(final List<String> elements) throws DataStoreException {
         final int size = elements.size();
-        final List<AbstractIdentifiedType> properties = new ArrayList<AbstractIdentifiedType>();
+        final List<AbstractIdentifiedType> properties = new ArrayList<>();
         for (int i=1; i<size; i++) {
             final String name = elements.get(i);
             Class<?> type = null;
@@ -386,22 +380,14 @@ public final class Store extends DataSto
                 String tn = elements.get(i);
                 if (!tn.isEmpty() && tn.regionMatches(true, 0, TYPE_PREFIX, 0, TYPE_PREFIX.length())) {
                     String st = tn.substring(TYPE_PREFIX.length()).toLowerCase(Locale.US);
-                    /*switch (st)*/ {
-                        if (st.equals("boolean")) {
-                            type = Boolean.class;
-                        } else if (st.equals("decimal")) {
-                            type = Double.class;
-                        } else if (st.equals("integer")) {
-                            type = Integer.class;
-                        } else if (st.equals("string")) {
-                            type = String.class;
-                        } else if (st.equals("datetime")) {
-                            type = Instant.class;
-                        } else if (st.equals("anyuri")) {
-                            type = URI.class;
-                        } else {
-                            throw new DataStoreContentException(errors().getString(Errors.Keys.UnknownType_1, tn));
-                        }
+                    switch (st) {
+                        case "boolean":  type = Boolean.class; break;
+                        case "decimal":  type = Double .class; break;
+                        case "integer":  type = Integer.class; break;
+                        case "string":   type = String .class; break;
+                        case "datetime": type = Instant.class; break;
+                        case "anyuri":   type = URI    .class; break;
+                        default: throw new DataStoreContentException(errors().getString(Errors.Keys.UnknownType_1, tn));
                     }
                 }
             }
@@ -445,7 +431,7 @@ public final class Store extends DataSto
      * Creates a property type for the given name and type.
      */
     private static AbstractIdentifiedType createProperty(final String name, final Class<?> type, final int minOccurrence) {
-        return new DefaultAttributeType(Collections.singletonMap(DefaultAttributeType.NAME_KEY, name), type, minOccurrence, 1, null);
+        return new DefaultAttributeType<>(Collections.singletonMap(DefaultAttributeType.NAME_KEY, name), type, minOccurrence, 1, null);
     }
 
     /**
@@ -505,7 +491,7 @@ public final class Store extends DataSto
             final String[]     propertyNames   = new String[converters.length];
             final boolean      hasTrajectories = this.hasTrajectories;
             final TimeEncoding timeEncoding    = this.timeEncoding;
-            final List<String> values          = new ArrayList<String>();
+            final List<String> values          = new ArrayList<>();
             int i = -1;
             for (final AbstractIdentifiedType p : properties) {
                 propertyNames[++i] = p.getName().tip().toString();
@@ -580,7 +566,7 @@ public final class Store extends DataSto
                 }
                 values.clear();
             }
-        } catch (Exception e) {     // Multi-catch on the JDK7 branch.
+        } catch (IOException | IllegalArgumentException | DateTimeException e) {
             throw new DataStoreException(errors().getString(Errors.Keys.CanNotParseFile_2, "CSV", name), e);
         }
         return features.iterator();

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -77,7 +77,7 @@ final class Store extends DataStore {
      * @throws DataStoreException if an error occurred while opening the stream.
      */
     public Store(final StorageConnector connector) throws DataStoreException {
-        objects = new ArrayList<Object>();
+        objects = new ArrayList<>();
         name    = connector.getStorageName();
         source  = connector.getStorageAs(Reader.class);
         connector.closeAllExcept(source);
@@ -126,9 +126,7 @@ final class Store extends DataStore {
                     listeners.warning(record);
                 }
             } while (pos.getIndex() < wkt.length());
-        } catch (IOException e) {                                       // Multi-catch on the JDK7 branch.
-            throw new DataStoreException(Errors.format(Errors.Keys.CanNotParseFile_2, "WKT", name), e);
-        } catch (ParseException e) {
+        } catch (IOException | ParseException e) {
             throw new DataStoreException(Errors.format(Errors.Keys.CanNotParseFile_2, "WKT", name), e);
         }
     }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -67,7 +67,7 @@ public class StoreProvider extends DataS
          */
         private Peek() {
             super(14);
-            final Set<String> s = new HashSet<String>(22);
+            final Set<String> s = new HashSet<>(22);
             s.add(WKTKeywords.GeodeticCRS);
             s.add(WKTKeywords.GeodCRS);
             s.add(WKTKeywords.GeogCS);

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -46,7 +46,7 @@ abstract class MimeTypeDetector {
      * The mapping from XML namespace to MIME type.
      * This map shall be read-only, since we do not synchronize it.
      */
-    private static final Map<String,String> TYPES = new HashMap<String,String>();
+    private static final Map<String,String> TYPES = new HashMap<>();
     static {
         TYPES.put(Namespaces.GML, "application/gml+xml");
         TYPES.put(Namespaces.GMD, "application/vnd.iso.19139+xml");

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -151,9 +151,7 @@ final class Store extends DataStore {
             } finally {
                 in.close();
             }
-        } catch (JAXBException e) {
-            throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, name), e);
-        } catch (IOException e) {
+        } catch (JAXBException | IOException e) {
             throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, name), e);
         }
     }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -24,9 +24,6 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.logging.WarningListener;
 import org.apache.sis.util.logging.WarningListeners;
 
-// Related to JDK7
-import org.apache.sis.internal.jdk7.AutoCloseable;
-
 
 /**
  * Manages a series of features, coverages or sensor data.
@@ -44,8 +41,7 @@ import org.apache.sis.internal.jdk7.Auto
  *
  * @see DataStores#open(Object)
  */
-@AutoCloseable
-public abstract class DataStore implements Localized {
+public abstract class DataStore implements Localized, AutoCloseable {
     /**
      * The locale to use for formatting warnings.
      *
@@ -63,8 +59,8 @@ public abstract class DataStore implemen
      * Creates a new instance with initially no listener.
      */
     protected DataStore() {
-        locale = Locale.getDefault();
-        listeners = new WarningListeners<DataStore>(this);
+        locale = Locale.getDefault(Locale.Category.DISPLAY);
+        listeners = new WarningListeners<>(this);
     }
 
     /**
@@ -147,5 +143,6 @@ public abstract class DataStore implemen
      *
      * @throws DataStoreException if an error occurred while closing this data store.
      */
+    @Override
     public abstract void close() throws DataStoreException;
 }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -88,7 +88,7 @@ final class DataStoreRegistry {
      * The {@code storage} argument can be any of the following types:
      *
      * <ul>
-     *   <li>A {@link java.io.File} for a file or a directory.</li>
+     *   <li>A {@link java.nio.file.Path} or a {@link java.io.File} for a file or a directory.</li>
      *   <li>A {@link java.net.URI} or a {@link java.net.URL} to a distant resource.</li>
      *   <li>A {@link java.lang.CharSequence} interpreted as a filename or a URL.</li>
      *   <li>A {@link java.nio.channels.Channel}, {@link java.io.DataInput}, {@link java.io.InputStream} or {@link java.io.Reader}.</li>
@@ -154,7 +154,7 @@ final class DataStoreRegistry {
                      * found an other provider.
                      */
                     if (deferred == null) {
-                        deferred = new LinkedList<ProbeProviderPair>();
+                        deferred = new LinkedList<>();
                     }
                     deferred.add(new ProbeProviderPair(provider, probe));
                 } else if (ProbeResult.UNDETERMINED.equals(probe)) {

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -93,7 +93,7 @@ public final class DataStores extends St
      * The {@code storage} argument can be any of the following types:
      *
      * <ul>
-     *   <li>A {@link java.io.File} for a file or a directory.</li>
+     *   <li>A {@link java.nio.file.Path} or a {@link java.io.File} for a file or a directory.</li>
      *   <li>A {@link java.net.URI} or a {@link java.net.URL} to a distant resource.</li>
      *   <li>A {@link java.lang.CharSequence} interpreted as a filename or a URL.</li>
      *   <li>A {@link java.nio.channels.Channel}, {@link java.io.DataInput}, {@link java.io.InputStream} or {@link java.io.Reader}.</li>

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -22,7 +22,7 @@ import org.apache.sis.util.Version;
 import org.apache.sis.internal.util.Utilities;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
 
 
 /**
@@ -290,7 +290,7 @@ public class ProbeResult implements Seri
         Object readResolve() {
             try {
                 return ProbeResult.class.getField(name).get(null);
-            } catch (Exception e) { // ReflectiveOperationException on the JDK7 branch.
+            } catch (ReflectiveOperationException e) {
                 return this; // See javadoc
             }
         }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -46,16 +46,13 @@ import org.apache.sis.internal.storage.C
 import org.apache.sis.internal.storage.ChannelImageInputStream;
 import org.apache.sis.setup.OptionKey;
 
-// Related to JDK7
-import org.apache.sis.internal.jdk7.JDK7;
-
 
 /**
  * Information for creating a connection to a {@link DataStore} in read and/or write mode.
  * {@code StorageConnector} wraps an input {@link Object}, which can be any of the following types:
  *
  * <ul>
- *   <li>A {@link java.io.File} for a file or a directory.</li>
+ *   <li>A {@link java.nio.file.Path} or a {@link java.io.File} for a file or a directory.</li>
  *   <li>A {@link java.net.URI} or a {@link java.net.URL} to a distant resource.</li>
  *   <li>A {@link CharSequence} interpreted as a filename or a URL.</li>
  *   <li>A {@link java.nio.channels.Channel}, {@link DataInput}, {@link InputStream} or {@link Reader}.</li>
@@ -228,8 +225,8 @@ public class StorageConnector implements
      * the following choices based on the type of the {@linkplain #getStorage() storage} object:
      *
      * <ul>
-     *   <li>For {@link java.io.File}, {@link java.net.URI} or {@link java.net.URL}
-     *       instances, this method uses dedicated API.</li>
+     *   <li>For {@link java.nio.file.Path}, {@link java.io.File}, {@link java.net.URI} or {@link java.net.URL}
+     *       instances, this method uses dedicated API like {@link java.nio.file.Path#getFileName()}.</li>
      *   <li>For {@link CharSequence} instances, this method gets a string representation of the storage object
      *       and returns the part after the last {@code '/'} character or platform-dependent name separator.</li>
      *   <li>For instances of unknown type, this method builds a string representation using the class name.
@@ -253,7 +250,7 @@ public class StorageConnector implements
      * the following choices based on the type of the {@linkplain #getStorage() storage} object:
      *
      * <ul>
-     *   <li>For {@link java.io.File}, {@link java.net.URI}, {@link java.net.URL} or
+     *   <li>For {@link java.nio.file.Path}, {@link java.io.File}, {@link java.net.URI}, {@link java.net.URL} or
      *       {@link CharSequence} instances, this method returns the string after the last {@code '.'} character
      *       in the filename, provided that the {@code '.'} is not the first filename character. This may be an
      *       empty string if the filename has no extension, but never {@code null}.</li>
@@ -277,7 +274,7 @@ public class StorageConnector implements
      * <ul>
      *   <li>{@link String}:
      *     <ul>
-     *       <li>If the {@linkplain #getStorage() storage} object is an instance of the
+     *       <li>If the {@linkplain #getStorage() storage} object is an instance of the {@link java.nio.file.Path},
      *           {@link java.io.File}, {@link java.net.URL}, {@link java.net.URI} or {@link CharSequence} types,
      *           returns the string representation of their path.</li>
      *
@@ -298,7 +295,7 @@ public class StorageConnector implements
      *           (including the {@link ImageInputStream} and {@link javax.imageio.stream.ImageOutputStream} types),
      *           then it is returned unchanged.</li>
      *
-     *       <li>Otherwise if the input is an instance of {@link java.io.File},
+     *       <li>Otherwise if the input is an instance of {@link java.nio.file.Path}, {@link java.io.File},
      *           {@link java.net.URI}, {@link java.net.URL}, {@link CharSequence}, {@link InputStream} or
      *           {@link java.nio.channels.ReadableByteChannel}, then an {@link ImageInputStream} backed by a
      *           {@link ByteBuffer} is created when first needed and returned.</li>
@@ -381,7 +378,7 @@ public class StorageConnector implements
                 return (view != Void.TYPE) ? type.cast(view) : null;
             }
         } else {
-            views = new IdentityHashMap<Class<?>, Object>();
+            views = new IdentityHashMap<>();
         }
         /*
          * Special case for DataInput and ByteBuffer, because those values are created together.
@@ -715,7 +712,7 @@ public class StorageConnector implements
      */
     private void addViewToClose(final Object input, final Object delegate) {
         if (viewsToClose == null) {
-            viewsToClose = new IdentityHashMap<Object,Object>(4);
+            viewsToClose = new IdentityHashMap<>(4);
         }
         if (viewsToClose.put(input, delegate) != null) {
             throw new AssertionError(input);
@@ -745,8 +742,8 @@ public class StorageConnector implements
         viewsToClose = Collections.emptyMap();
         views        = Collections.emptyMap();
         if (toClose == null) {
-            if (storage != view && JDK7.isAutoCloseable(storage)) try {
-                JDK7.close(storage);
+            if (storage != view && storage instanceof AutoCloseable) try {
+                ((AutoCloseable) storage).close();
             } catch (Exception e) {
                 throw new DataStoreException(e);
             }
@@ -774,7 +771,7 @@ public class StorageConnector implements
              * Those wrappers shall not be closed. For example if the caller does not want to close the
              * InputStream view, then we shall not close the InputStreamReader wrapper neither.
              */
-            final Queue<Object> deferred = new LinkedList<Object>();
+            final Queue<Object> deferred = new LinkedList<>();
             Object doNotClose = view;
             do {
                 final Iterator<Map.Entry<Object,Object>> it = toClose.entrySet().iterator();
@@ -809,13 +806,13 @@ public class StorageConnector implements
          */
         DataStoreException failure = null;
         for (final Object c : toClose.keySet()) {
-            if (JDK7.isAutoCloseable(c)) try {
-                JDK7.close(c);
+            if (c instanceof AutoCloseable) try {
+                ((AutoCloseable) c).close();
             } catch (Exception e) {
                 if (failure == null) {
                     failure = new DataStoreException(e);
                 } else {
-                    // failure.addSuppressed(e) on the JDK7 branch.
+                    failure.addSuppressed(e);
                 }
             }
         }

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -22,7 +22,7 @@ import java.nio.channels.ClosedChannelEx
 import org.apache.sis.util.ArgumentChecks;
 
 // Branch-dependent imports
-import java.nio.channels.ByteChannel;
+import java.nio.channels.SeekableByteChannel;
 
 
 /**
@@ -38,7 +38,7 @@ import java.nio.channels.ByteChannel;
  * @see ChannelDataOutputTest
  * @see ChannelImageOutputStream
  */
-final strictfp class ByteArrayChannel implements ByteChannel {
+final strictfp class ByteArrayChannel implements SeekableByteChannel {
     /**
      * Bytes array where to write the data.
      * The length of this array is the capacity.
@@ -105,6 +105,7 @@ final strictfp class ByteArrayChannel im
     /**
      * Returns this channel position.
      */
+    @Override
     public long position() throws IOException {
         ensureOpen();
         return position;
@@ -113,7 +114,8 @@ final strictfp class ByteArrayChannel im
     /**
      * Sets this channel position.
      */
-    public ByteArrayChannel position(final long newPosition) throws IOException {
+    @Override
+    public SeekableByteChannel position(final long newPosition) throws IOException {
         ensureOpen();
         ArgumentChecks.ensureBetween("position", 0, data.length, newPosition);
         position = (int) newPosition;
@@ -123,6 +125,7 @@ final strictfp class ByteArrayChannel im
     /**
      * Returns the current size.
      */
+    @Override
     public long size() throws IOException {
         ensureOpen();
         return limit;
@@ -131,7 +134,8 @@ final strictfp class ByteArrayChannel im
     /**
      * Truncates the data to the given size.
      */
-    public ByteArrayChannel truncate(final long size) throws IOException {
+    @Override
+    public SeekableByteChannel truncate(final long size) throws IOException {
         ensureOpen();
         ArgumentChecks.ensureBetween("position", 0, limit, size);
         limit = (int) size;

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -140,14 +140,6 @@ public strictfp class ChannelDataOutputT
         final ByteBuffer arrayView = ByteBuffer.wrap(expectedArray);
         for (int i=0; i<100; i++) {
             final int position = random.nextInt(seekRange);
-
-            // JDK6 specific: can not seek to arbitrary position because
-            // Java 6 does not provide the SeekableByteChannel interface.
-            if (position < testedStream.getFlushedPosition()) {
-                continue;
-            }
-            // End of JDK6 specific.
-
             testedStream.seek(position);
             assertEquals("getStreamPosition()", position, testedStream.getStreamPosition());
             final long v = random.nextLong();

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -108,7 +108,7 @@ abstract strictfp class ChannelDataTestC
                 operation = random.nextInt(numOperations);
                 transferRandomData(operation);
             }
-        } catch (AssertionError e) {
+        } catch (AssertionError | RuntimeException e) {
             out.println("Iter. count: " + count);
             out.println("Position:    " + position);
             out.println("Bit offset:  " + bitOffset);

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -87,7 +87,7 @@ public final strictfp class ChannelImage
      */
     @Test
     public void testMarkAndReset() throws IOException {
-        initialize("testMarkAndReset", STREAM_LENGTH, STREAM_LENGTH); // We need a larger buffer for this test.
+        initialize("testMarkAndReset", STREAM_LENGTH, 1000); // We need a larger buffer for this test.
         final ImageOutputStream referenceStream = (ImageOutputStream) this.referenceStream;
         /*
          * Fill both streams with random data.

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -32,9 +32,7 @@ import org.apache.sis.util.Workaround;
  * @module
  */
 @Workaround(library = "JDK", version = "1.8")
-final strictfp class MemoryCacheImageOutputStream extends javax.imageio.stream.MemoryCacheImageOutputStream
-        implements java.io.Closeable    // Needed on JDK 6 only.
-{
+final strictfp class MemoryCacheImageOutputStream extends javax.imageio.stream.MemoryCacheImageOutputStream {
     /**
      * Creates a new instance which will write the data in the given stream.
      */

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -65,11 +65,8 @@ public final class StoreTest extends Tes
     @org.junit.Ignore("Pending completion of sis-referencing")
     public void testGetMetadata() throws DataStoreException {
         final Metadata metadata;
-        Store store = new Store(new StorageConnector(new StringReader(TEST_DATA)));
-        try {
+        try (Store store = new Store(new StorageConnector(new StringReader(TEST_DATA)))) {
             metadata = store.getMetadata();
-        } finally {
-            store.close();
         }
         final AbstractIdentification id = (AbstractIdentification) getSingleton(metadata.getIdentificationInfo());
         final SpatialTemporalExtent extent = (SpatialTemporalExtent) getSingleton(getSingleton(id.getExtents()).getTemporalElements());
@@ -89,16 +86,13 @@ public final class StoreTest extends Tes
      */
     @Test
     public void testGetFeatures() throws DataStoreException {
-        Store store = new Store(new StorageConnector(new StringReader(TEST_DATA)));
-        try {
+        try (Store store = new Store(new StorageConnector(new StringReader(TEST_DATA)))) {
             final Iterator<AbstractFeature> it = store.getFeatures();
             assertFeatureEquals(it.next(), "a", new double[] {11, 2, 12, 3},        "walking", 1);
             assertFeatureEquals(it.next(), "b", new double[] {10, 2, 11, 3},        "walking", 2);
             assertFeatureEquals(it.next(), "a", new double[] {12, 3, 10, 3},        "walking", 2);
             assertFeatureEquals(it.next(), "c", new double[] {12, 1, 10, 2, 11, 3}, "vehicle", 1);
             assertFalse(it.hasNext());
-        } finally {
-            store.close();
         }
     }
 

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -31,7 +31,7 @@ import org.junit.Test;
 import static org.apache.sis.test.Assert.*;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk7.StandardCharsets;
+import java.nio.charset.StandardCharsets;
 
 
 /**
@@ -73,12 +73,9 @@ public final strictfp class StoreTest ex
     @Test
     public void testFromReader() throws DataStoreException {
         final Metadata metadata;
-        final Store store = new Store(new StorageConnector(new StringReader(WKT)));
-        try {
+        try (Store store = new Store(new StorageConnector(new StringReader(WKT)))) {
             metadata = store.getMetadata();
             assertSame("Expected cached value.", metadata, store.getMetadata());
-        } finally {
-            store.close();
         }
         validate((GeographicCRS) TestUtilities.getSingleton(metadata.getReferenceSystemInfo()));
     }
@@ -96,12 +93,9 @@ public final strictfp class StoreTest ex
         final StoreProvider p = new StoreProvider();
         final StorageConnector c = new StorageConnector(new ByteArrayInputStream(StoreTest.WKT.getBytes(StandardCharsets.US_ASCII)));
         assertTrue("isSupported", p.probeContent(c).isSupported());
-        final Store store = new Store(c);
-        try {
+        try (Store store = new Store(c)) {
             metadata = store.getMetadata();
             assertSame("Expected cached value.", metadata, store.getMetadata());
-        } finally {
-            store.close();
         }
         validate((GeographicCRS) TestUtilities.getSingleton(metadata.getReferenceSystemInfo()));
     }

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -91,12 +91,9 @@ public final strictfp class StoreTest ex
     @Test
     public void testMetadata() throws DataStoreException {
         final Metadata metadata;
-        final Store store = new Store(new StorageConnector(new StringReader(XML)));
-        try {
+        try (Store store = new Store(new StorageConnector(new StringReader(XML)))) {
             metadata = store.getMetadata();
             assertSame("Expected cached value.", metadata, store.getMetadata());
-        } finally {
-            store.close();
         }
         final ResponsibleParty resp     = getSingleton(metadata.getContacts());
         final Contact          contact  = resp.getContactInfo();



Mime
View raw message