From 706d630eb9db9658083d57d1d99b6a0f11cc5657 Mon Sep 17 00:00:00 2001 From: Kihwal Lee Date: Tue, 17 Jan 2017 15:10:24 -0600 Subject: [PATCH] HADOOP-13976. Path globbing does not match newlines. Contributed by Eric Badger. --- .../src/main/java/org/apache/hadoop/fs/GlobPattern.java | 2 +- .../test/java/org/apache/hadoop/fs/TestGlobPattern.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobPattern.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobPattern.java index 16505a62ca..c5cf3d2323 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobPattern.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobPattern.java @@ -153,7 +153,7 @@ public void set(String glob) { if (curlyOpen > 0) { error("Unclosed group", glob, len); } - compiled = Pattern.compile(regex.toString()); + compiled = Pattern.compile(regex.toString(), Pattern.DOTALL); } /** diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGlobPattern.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGlobPattern.java index 356c442946..99cb645e82 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGlobPattern.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGlobPattern.java @@ -50,11 +50,11 @@ private void shouldThrow(String... globs) { } @Test public void testValidPatterns() { - assertMatch(true, "*", "^$", "foo", "bar"); + assertMatch(true, "*", "^$", "foo", "bar", "\n"); assertMatch(true, "?", "?", "^", "[", "]", "$"); - assertMatch(true, "foo*", "foo", "food", "fool"); - assertMatch(true, "f*d", "fud", "food"); - assertMatch(true, "*d", "good", "bad"); + assertMatch(true, "foo*", "foo", "food", "fool", "foo\n", "foo\nbar"); + assertMatch(true, "f*d", "fud", "food", "foo\nd"); + assertMatch(true, "*d", "good", "bad", "\nd"); assertMatch(true, "\\*\\?\\[\\{\\\\", "*?[{\\"); assertMatch(true, "[]^-]", "]", "-", "^"); assertMatch(true, "]", "]");