You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2022/05/18 14:12:25 UTC

[sis] branch geoapi-4.0 updated (40350f09ea -> ceb6064e23)

This is an automated email from the ASF dual-hosted git repository.

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


 discard 40350f09ea Add missing synchronization.
     new ceb6064e23 Add missing synchronization.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (40350f09ea)
            \
             N -- N -- N   refs/heads/geoapi-4.0 (ceb6064e23)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/sis/storage/geotiff/GeoTiffStore.java  | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)


[sis] 01/01: Add missing synchronization.

Posted by de...@apache.org.
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 ceb6064e23878d6bcbf6305154f542e8749c1675
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed May 18 15:14:57 2022 +0200

    Add missing synchronization.
---
 .../apache/sis/storage/geotiff/GeoTiffStore.java   | 23 ++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
index d0a2c77d26..859cb69e3d 100644
--- a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
+++ b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
@@ -65,7 +65,7 @@ import org.apache.sis.util.resources.Errors;
  * @author  Rémi Maréchal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Thi Phuong Hao Nguyen (VNSC)
- * @version 1.2
+ * @version 1.3
  * @since   0.8
  * @module
  */
@@ -381,6 +381,7 @@ public class GeoTiffStore extends DataStore implements Aggregate {
      * @see #close()
      */
     private Reader reader() throws DataStoreException {
+        assert Thread.holdsLock(this);
         final Reader r = reader;
         if (r == null) {
             throw new DataStoreClosedException(getLocale(), Constants.GEOTIFF, StandardOpenOption.READ);
@@ -402,7 +403,7 @@ public class GeoTiffStore extends DataStore implements Aggregate {
      */
     @Override
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
-    public List<GridCoverageResource> components() throws DataStoreException {
+    public synchronized List<GridCoverageResource> components() throws DataStoreException {
         if (components == null) {
             components = new Components();
         }
@@ -420,15 +421,19 @@ public class GeoTiffStore extends DataStore implements Aggregate {
 
         /** Returns the size or -1 if not yet known. */
         @Override protected int sizeIfKnown() {
-            return size;
+            synchronized (GeoTiffStore.this) {
+                return size;
+            }
         }
 
         /** Returns the size, computing and caching it if needed. */
         @Override public int size() {
-            if (size < 0) {
-                size = super.size();
+            synchronized (GeoTiffStore.this) {
+                if (size < 0) {
+                    size = super.size();
+                }
+                return size;
             }
-            return size;
         }
 
         /** Returns whether the given index is valid. */
@@ -448,7 +453,9 @@ public class GeoTiffStore extends DataStore implements Aggregate {
         /** Returns element at the given index or returns {@code null} if the index is invalid. */
         private GridCoverageResource getImageFileDirectory(final int index) {
             try {
-                return reader().getImage(index);
+                synchronized (GeoTiffStore.this) {
+                    return reader().getImage(index);
+                }
             } catch (IOException e) {
                 throw new BackingStoreException(errorIO(e));
             } catch (DataStoreException e) {
@@ -465,7 +472,7 @@ public class GeoTiffStore extends DataStore implements Aggregate {
      * @throws DataStoreException if the requested image can not be obtained.
      */
     @Override
-    public GridCoverageResource findResource(final String sequence) throws DataStoreException {
+    public synchronized GridCoverageResource findResource(final String sequence) throws DataStoreException {
         Exception cause;
         int index;
         try {