sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/04: Document the new synchronization policy of DataStores.
Date Tue, 04 Jun 2019 16:21:28 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 7696815326cf1c3f928ba01246f8fea46ff872da
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Jun 4 17:14:47 2019 +0200

    Document the new synchronization policy of DataStores.
---
 .../src/main/java/org/apache/sis/storage/DataStore.java    | 14 ++++++++++++--
 .../java/org/apache/sis/internal/storage/gpx/Store.java    |  4 +---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
index 7a23148..54e981f 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
@@ -48,8 +48,17 @@ import org.apache.sis.referencing.NamedIdentifier;
  * while a {@code DataStore} for netCDF files will implement the {@link Aggregate} interface.</p>
  *
  * <div class="section">Thread safety policy</div>
- * This {@code DataStore} base class is thread-safe. However subclasses do not need to be
thread-safe.
- * Unless otherwise specified, users should assume that {@code DataStore} instances are not
thread-safe.
+ * Data stores should be thread-safe, but their synchronization lock is implementation-dependent.
+ * This base class uses only the {@code synchronized} keyword, applied on the following methods:
+ *
+ * <ul>
+ *   <li>{@link #getLocale()}</li>
+ *   <li>{@link #setLocale(Locale)}</li>
+ * </ul>
+ *
+ * Since above properties are used only for information purpose, concurrent modifications
during a read or write
+ * operation should be harmless. Consequently subclasses are free use their own synchronization
mechanism instead
+ * than {@code synchronized(this)} lock.
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -208,6 +217,7 @@ public abstract class DataStore implements Resource, Localized, AutoCloseable
{
         ArgumentChecks.ensureNonNull("locale", locale);
         this.locale = locale;
     }
+    // See class javadoc for a note on synchronization.
 
     /**
      * The locale to use for formatting warnings and other messages. This locale if for user
interfaces
diff --git a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
index ad2615e..1e20adf 100644
--- a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
+++ b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
@@ -239,9 +239,7 @@ public final class Store extends StaxDataStore implements FeatureSet {
      * @throws ConcurrentReadException if the {@code features} stream was provided by this
data store.
      * @throws DataStoreException if an error occurred while writing the data.
      */
-    public synchronized void write(final Metadata metadata, final Stream<? extends Feature>
features)
-            throws DataStoreException
-    {
+    public synchronized void write(final Metadata metadata, final Stream<? extends Feature>
features) throws DataStoreException {
         try {
             /*
              * If we created a reader for reading metadata, we need to close that reader
now otherwise the call


Mime
View raw message