sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1759700 - in /sis/branches/JDK8/storage: sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/ sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/ sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/ si...
Date Wed, 07 Sep 2016 20:48:44 GMT
Author: desruisseaux
Date: Wed Sep  7 20:48:43 2016
New Revision: 1759700

URL: http://svn.apache.org/viewvc?rev=1759700&view=rev
Log:
Add defensive synchronization. The DataStore javadoc said that implementations do not need
to be thread-safe,
but we nevertheless synchronize since DataStore are often used in multi-thread context and
the user may forget to perform his own synchronization.

Modified:
    sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java

Modified: sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java?rev=1759700&r1=1759699&r2=1759700&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java
[UTF-8] Wed Sep  7 20:48:43 2016
@@ -107,7 +107,7 @@ public class LandsatStore extends DataSt
      * @throws DataStoreException if an error occurred while reading the data.
      */
     @Override
-    public Metadata getMetadata() throws DataStoreException {
+    public synchronized Metadata getMetadata() throws DataStoreException {
         if (metadata == null && source != null) try {
             try (BufferedReader reader = (source instanceof BufferedReader) ? (BufferedReader)
source : new LineNumberReader(source)) {
                 source = null;      // Will be closed at the end of this try-catch block.
@@ -129,7 +129,7 @@ public class LandsatStore extends DataSt
      * @throws DataStoreException if an error occurred while closing the Landsat file.
      */
     @Override
-    public void close() throws DataStoreException {
+    public synchronized void close() throws DataStoreException {
         metadata = null;
     }
 

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1759700&r1=1759699&r2=1759700&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
[UTF-8] Wed Sep  7 20:48:43 2016
@@ -83,7 +83,7 @@ public class NetcdfStore extends DataSto
      * @throws DataStoreException if an error occurred while reading the data.
      */
     @Override
-    public Metadata getMetadata() throws DataStoreException {
+    public synchronized Metadata getMetadata() throws DataStoreException {
         if (metadata == null) try {
             final MetadataReader reader = new MetadataReader(decoder);
             metadata = reader.read();
@@ -102,7 +102,7 @@ public class NetcdfStore extends DataSto
      * @throws DataStoreException if an error occurred while closing the NetCDF file.
      */
     @Override
-    public void close() throws DataStoreException {
+    public synchronized void close() throws DataStoreException {
         metadata = null;
         try {
             decoder.close();

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1759700&r1=1759699&r2=1759700&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] Wed Sep  7 20:48:43 2016
@@ -140,7 +140,7 @@ final class Store extends DataStore {
      * @throws DataStoreException if an error occurred during the parsing process.
      */
     @Override
-    public Metadata getMetadata() throws DataStoreException {
+    public synchronized Metadata getMetadata() throws DataStoreException {
         if (metadata == null) {
             parse();
             DefaultMetadata md = null;
@@ -161,7 +161,7 @@ final class Store extends DataStore {
      * @throws DataStoreException if an error occurred while closing this data store.
      */
     @Override
-    public void close() throws DataStoreException {
+    public synchronized void close() throws DataStoreException {
         final Reader s = source;
         source = null;                  // Cleared first in case of failure.
         objects.clear();

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1759700&r1=1759699&r2=1759700&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] Wed Sep  7 20:48:43 2016
@@ -168,11 +168,11 @@ final class Store extends DataStore {
      *
      * Other cases may be added in any future SIS version.
      *
-     * @return The metadata associated to the unmarshalled object, or {@code null} if none.
+     * @return the metadata associated to the unmarshalled object, or {@code null} if none.
      * @throws DataStoreException if an error occurred during the unmarshalling process.
      */
     @Override
-    public Metadata getMetadata() throws DataStoreException {
+    public synchronized Metadata getMetadata() throws DataStoreException {
         if (metadata == null) {
             unmarshal();
             if (object instanceof Metadata) {
@@ -192,7 +192,7 @@ final class Store extends DataStore {
      * @throws DataStoreException if an error occurred while closing this data store.
      */
     @Override
-    public void close() throws DataStoreException {
+    public synchronized void close() throws DataStoreException {
         object = null;
         final Closeable in = input(source);
         source = null;                          // Cleared first in case of failure.



Mime
View raw message