You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by hz...@apache.org on 2016/03/01 23:36:15 UTC

[29/37] incubator-trafodion git commit: reduce data copy and close sequence

reduce data copy and close sequence


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/f530cfee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/f530cfee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/f530cfee

Branch: refs/heads/master
Commit: f530cfee3795235ab730843a84c0b703e907d6f8
Parents: 35664a3
Author: Kevin Xu <ka...@esgyn.cn>
Authored: Mon Jan 18 15:55:19 2016 +0800
Committer: Kevin Xu <ka...@esgyn.cn>
Committed: Mon Jan 18 15:55:19 2016 +0800

----------------------------------------------------------------------
 .../src/main/java/org/trafodion/libmgmt/FileMgmt.java     | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f530cfee/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java
----------------------------------------------------------------------
diff --git a/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java b/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java
index 8dd8f4e..94f7d65 100644
--- a/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java
+++ b/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java
@@ -413,17 +413,19 @@ public class FileMgmt {
 				fos = new FileOutputStream(fname, (appendFlag == 0));
 				channel = fos.getChannel();
 				lock = channel.tryLock();
-				fos.write(Arrays.copyOf(data, data.length));
-				fos.flush();
+				if (lock != null) {
+					fos.write(data);
+					fos.flush();
+				}
 			} finally {
-				if (fos != null)
-					fos.close();
 				if(lock != null){
 					lock.release();
 				}
 				if(channel !=null){
 					channel.close();
 				}
+				if (fos != null)
+					fos.close();
 			}
 
 			syncJar(userPath, fileName);