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
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 40350f09ea Add missing synchronization.
40350f09ea is described below
commit 40350f09ea8ef63179de7cd6b68e8005cd5f8950
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Wed May 18 15:14:57 2022 +0200
Add missing synchronization.
---
.../main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 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..e3a83a0027 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);
@@ -448,7 +449,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 +468,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 {