ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/7] ignite git commit: IGNITE-4862: Fixed NPE when reading data from IGFS. This closes #1706.
Date Tue, 19 Dec 2017 11:34:35 GMT
IGNITE-4862: Fixed NPE when reading data from IGFS. This closes #1706.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5cd3e263
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5cd3e263
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5cd3e263

Branch: refs/heads/ignite-zk-ce
Commit: 5cd3e263b9ca1464044c1eec24fc642873a881ab
Parents: edc66af
Author: Ilya Kasnacheev <ilya.kasnacheev@gmail.com>
Authored: Mon Dec 18 15:58:10 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Mon Dec 18 15:58:10 2017 +0300

----------------------------------------------------------------------
 .../processors/igfs/IgfsDataManager.java        |  4 +-
 ...zySecondaryFileSystemPositionedReadable.java | 15 +++++--
 ...fsSecondaryFileSystemPositionedReadable.java | 41 ++++++++++++--------
 3 files changed, 38 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5cd3e263/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index 12765df..90b5e9b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -419,9 +419,11 @@ public class IgfsDataManager extends IgfsManager {
         int read = 0;
 
         try {
+            int r;
+
             // Delegate to the secondary file system.
             while (read < blockSize) {
-                int r = secReader.read(pos + read, res, read, blockSize - read);
+                r = secReader.read(pos + read, res, read, blockSize - read);
 
                 if (r < 0)
                     break;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5cd3e263/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLazySecondaryFileSystemPositionedReadable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLazySecondaryFileSystemPositionedReadable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLazySecondaryFileSystemPositionedReadable.java
index 0a57c34..bbb5420 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLazySecondaryFileSystemPositionedReadable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLazySecondaryFileSystemPositionedReadable.java
@@ -37,6 +37,9 @@ public class IgfsLazySecondaryFileSystemPositionedReadable implements IgfsSecond
     /** Buffer size. */
     private final int bufSize;
 
+    /** Synchronization mutex. */
+    private final Object mux = new Object();
+
     /** Target stream. */
     private IgfsSecondaryFileSystemPositionedReadable target;
 
@@ -58,16 +61,20 @@ public class IgfsLazySecondaryFileSystemPositionedReadable implements
IgfsSecond
 
     /** {@inheritDoc} */
     @Override public int read(long pos, byte[] buf, int off, int len) throws IOException
{
-        if (target == null)
-            target = fs.open(path, bufSize);
+        synchronized (mux) {
+            if (target == null)
+                target = fs.open(path, bufSize);
+        }
 
         return target.read(pos, buf, off, len);
     }
 
     /** {@inheritDoc} */
     @Override public void close() throws IOException {
-        if (target != null)
-            target.close();
+        synchronized (mux) {
+            if (target != null)
+                target.close();
+        }
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/5cd3e263/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java
index 1a4add5..84f6283 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java
@@ -42,6 +42,9 @@ public class HadoopIgfsSecondaryFileSystemPositionedReadable implements
IgfsSeco
     /** Buffer size. */
     private final int bufSize;
 
+    /** Synchronization mutex. */
+    private final Object mux = new Object();
+
     /** Actual input stream. */
     private FSDataInputStream in;
 
@@ -69,34 +72,38 @@ public class HadoopIgfsSecondaryFileSystemPositionedReadable implements
IgfsSeco
 
     /** Get input stream. */
     private PositionedReadable in() throws IOException {
-        if (opened) {
-            if (err != null)
-                throw err;
-        }
-        else {
-            opened = true;
+        synchronized (mux) {
+            if (opened) {
+                if (err != null)
+                    throw err;
+            }
+            else {
+                opened = true;
 
-            try {
-                in = fs.open(path, bufSize);
+                try {
+                    in = fs.open(path, bufSize);
 
-                if (in == null)
-                    throw new IOException("Failed to open input stream (file system returned
null): " + path);
-            }
-            catch (IOException e) {
-                err = e;
+                    if (in == null)
+                        throw new IOException("Failed to open input stream (file system returned
null): " + path);
+                }
+                catch (IOException e) {
+                    err = e;
 
-                throw err;
+                    throw err;
+                }
             }
-        }
 
-        return in;
+            return in;
+        }
     }
 
     /**
      * Close wrapped input stream in case it was previously opened.
      */
     @Override public void close() {
-        U.closeQuiet(in);
+        synchronized (mux) {
+            U.closeQuiet(in);
+        }
     }
 
     /** {@inheritDoc} */


Mime
View raw message