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

pboado pushed a commit to branch 5.x-cdh6
in repository https://gitbox.apache.org/repos/asf/phoenix.git

commit 3ac1a4830a8aa6140c2491dc2417551453baf590
Author: Aman Poonia <aman.poonia...@gmail.com>
AuthorDate: Mon Mar 11 17:44:23 2019 +0000

    PHOENIX-5187 Avoid using FileInputStream and FileOutputStream
---
 .../main/java/org/apache/phoenix/cache/ServerCacheClient.java    | 9 +++++----
 .../src/main/java/org/apache/phoenix/iterate/BufferedQueue.java  | 7 +++----
 .../java/org/apache/phoenix/iterate/SpoolingResultIterator.java  | 4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
index 822e255..bb96637 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
@@ -22,9 +22,10 @@ import static 
org.apache.phoenix.util.LogUtil.addCustomAnnotations;
 
 import java.io.Closeable;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -148,7 +149,7 @@ public class ServerCacheClient {
                 } catch (InsufficientMemoryException e) {
                     this.outputFile = 
File.createTempFile("HashJoinCacheSpooler", ".bin", new File(services.getProps()
                             .get(QueryServices.SPOOL_DIRECTORY, 
QueryServicesOptions.DEFAULT_SPOOL_DIRECTORY)));
-                    try (FileOutputStream fio = new 
FileOutputStream(outputFile)) {
+                    try (OutputStream fio = 
Files.newOutputStream(outputFile.toPath())) {
                         fio.write(cachePtr.get(), cachePtr.getOffset(), 
cachePtr.getLength());
                     }
                 }
@@ -158,7 +159,7 @@ public class ServerCacheClient {
 
         public ImmutableBytesWritable getCachePtr() throws IOException {
             if(this.outputFile!=null){
-                try (FileInputStream fio = new FileInputStream(outputFile)) {
+                try (InputStream fio = 
Files.newInputStream(outputFile.toPath())) {
                     byte[] b = new byte[this.size];
                     fio.read(b);
                     cachePtr = new ImmutableBytesWritable(b);
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BufferedQueue.java 
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BufferedQueue.java
index 1a646e6..3352641 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BufferedQueue.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BufferedQueue.java
@@ -23,9 +23,8 @@ import java.io.Closeable;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.nio.file.Files;
 import java.util.AbstractQueue;
 import java.util.Comparator;
 import java.util.Iterator;
@@ -304,7 +303,7 @@ public abstract class BufferedQueue<T> extends 
AbstractQueue<T> implements SizeA
             if (totalResultSize >= thresholdBytes) {
                 this.file = File.createTempFile(UUID.randomUUID().toString(), 
null);
                 try (DataOutputStream out = new DataOutputStream(
-                        new BufferedOutputStream(new FileOutputStream(file)))) 
{
+                        new 
BufferedOutputStream(Files.newOutputStream(file.toPath())))) {
                     int resSize = inMemQueue.size();
                     for (int i = 0; i < resSize; i++) {
                         T e = inMemQueue.poll();
@@ -342,7 +341,7 @@ public abstract class BufferedQueue<T> extends 
AbstractQueue<T> implements SizeA
                 this.next = null;
                 try {
                     this.in = new DataInputStream(
-                            new BufferedInputStream(new 
FileInputStream(file)));
+                            new 
BufferedInputStream(Files.newInputStream(file.toPath())));
                 } catch (IOException e) {
                     throw new RuntimeException(e);
                 }
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java
index fa90b1a..0823026 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java
@@ -27,8 +27,8 @@ import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.EOFException;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
+import java.nio.file.Files;
 import java.sql.SQLException;
 import java.util.List;
 
@@ -273,7 +273,7 @@ public class SpoolingResultIterator implements 
PeekingResultIterator {
 
         private synchronized void init() throws IOException {
             if (spoolFrom == null) {
-                spoolFrom = new DataInputStream(new BufferedInputStream(new 
FileInputStream(file)));
+                spoolFrom = new DataInputStream(new 
BufferedInputStream(Files.newInputStream(file.toPath())));
                 advance();
             }
         }

Reply via email to