This is an automated email from the ASF dual-hosted git repository.
asalamon74 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/oozie.git
The following commit(s) were added to refs/heads/master by this push:
new dd8c247 OOZIE-3524 fs:fileSize() does not work correctly for files
with extra slash in path (mgogineni via asalamon74)
dd8c247 is described below
commit dd8c24740240e7f967c586eed839c22f2c938e22
Author: Andras Salamon <[email protected]>
AuthorDate: Tue Jul 16 09:36:43 2019 +0200
OOZIE-3524 fs:fileSize() does not work correctly for files with extra slash
in path (mgogineni via asalamon74)
---
.../org/apache/oozie/action/hadoop/FsELFunctions.java | 18 +++++++-----------
.../apache/oozie/action/hadoop/TestFsELFunctions.java | 14 ++++++++++++++
release-log.txt | 1 +
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git
a/core/src/main/java/org/apache/oozie/action/hadoop/FsELFunctions.java
b/core/src/main/java/org/apache/oozie/action/hadoop/FsELFunctions.java
index 55be949..0f81d76 100644
--- a/core/src/main/java/org/apache/oozie/action/hadoop/FsELFunctions.java
+++ b/core/src/main/java/org/apache/oozie/action/hadoop/FsELFunctions.java
@@ -58,11 +58,9 @@ public class FsELFunctions {
* @throws Exception in case of file system issue
*/
private static FileStatus getFileStatus(String pathUri) throws Exception {
- URI uri = new URI(pathUri);
- String path = uri.getPath();
- FileSystem fs = getFileSystem(uri);
- Path p = new Path(path);
- return fs.exists(p) ? fs.getFileStatus(p) : null;
+ Path path = new Path(pathUri);
+ FileSystem fs = getFileSystem(path.toUri());
+ return fs.exists(path) ? fs.getFileStatus(path) : null;
}
/**
@@ -126,14 +124,12 @@ public class FsELFunctions {
* @throws Exception in case of file system issue
*/
public static long fs_dirSize(String pathUri) throws Exception {
- URI uri = new URI(pathUri);
- String path = uri.getPath();
+ Path path = new Path(pathUri);
long size = -1;
try {
- FileSystem fs = getFileSystem(uri);
- Path p = new Path(path);
- if (fs.exists(p) && !fs.isFile(p)) {
- FileStatus[] stati = fs.listStatus(p);
+ FileSystem fs = getFileSystem(path.toUri());
+ if (fs.exists(path) && !fs.isFile(path)) {
+ FileStatus[] stati = fs.listStatus(path);
size = 0;
if (stati != null) {
for (FileStatus status : stati) {
diff --git
a/core/src/test/java/org/apache/oozie/action/hadoop/TestFsELFunctions.java
b/core/src/test/java/org/apache/oozie/action/hadoop/TestFsELFunctions.java
index 857010d..7b8187e 100644
--- a/core/src/test/java/org/apache/oozie/action/hadoop/TestFsELFunctions.java
+++ b/core/src/test/java/org/apache/oozie/action/hadoop/TestFsELFunctions.java
@@ -20,6 +20,7 @@ package org.apache.oozie.action.hadoop;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
+import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.hadoop.conf.Configuration;
@@ -75,6 +76,13 @@ public class TestFsELFunctions extends XFsTestCase {
os.write(arr);
os.close();
+ URI filebURI = new Path(dir, "b").toUri();
+ String filebExtraSlashInPath = new URI(filebURI.getScheme(),
filebURI.getAuthority(),
+ "/" + filebURI.getPath(), null, null).toString();
+ URI dirURI = new Path(dir).toUri();
+ String dirExtraSlashInPath = new URI(dirURI.getScheme(),
dirURI.getAuthority(),
+ "/" + dirURI.getPath(), null, null).toString();
+
Configuration conf = new XConfiguration();
conf.set(OozieClient.APP_PATH, "appPath");
conf.set(OozieClient.USER_NAME, getTestUser());
@@ -87,6 +95,8 @@ public class TestFsELFunctions extends XFsTestCase {
conf.set("file5", getFsTestCaseDir()+"/file*");
conf.set("file6", getFsTestCaseDir()+"/file_*");
conf.set("dir", dir);
+ conf.set("dirExtraSlashInPath", dirExtraSlashInPath);
+ conf.set("filebExtraSlashInPath", filebExtraSlashInPath);
LiteWorkflowApp def =
new LiteWorkflowApp("name", "<workflow-app/>",
@@ -124,6 +134,10 @@ public class TestFsELFunctions extends XFsTestCase {
assertEquals(3, (int) eval.evaluate("${fs:dirSize(wf:conf('dir'))}",
Integer.class));
assertEquals(-1, (int)
eval.evaluate("${fs:blockSize(wf:conf('file2'))}", Integer.class));
assertTrue(eval.evaluate("${fs:blockSize(wf:conf('file1'))}",
Integer.class) > 0);
+ assertEquals("Size of fileb with extra slash in path should be 2",
+ 2, (int)
eval.evaluate("${fs:fileSize(wf:conf('filebExtraSlashInPath'))}",
Integer.class));
+ assertEquals("Size of dir with extra slash in path should be 3",
+ 3, (int)
eval.evaluate("${fs:dirSize(wf:conf('dirExtraSlashInPath'))}", Integer.class));
}
}
diff --git a/release-log.txt b/release-log.txt
index 1a68737..a1de03e 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 5.2.0 release (trunk - unreleased)
+OOZIE-3524 fs:fileSize() does not work correctly for files with extra slash in
path (mgogineni via asalamon74)
OOZIE-3523 First missing dependency is shown incorrectly (mgogineni via
asalamon74)
OOZIE-2836 Remove .ps1 and .cmd windows scripts (kmarton via asalamon74)
OOZIE-3506 Flaky test TestOozieRollingPolicy (asalamon74 via kmarton)