flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject git commit: FLUME-2472. SyslogUtils fails when system locale is not English
Date Fri, 10 Oct 2014 06:18:18 GMT
Repository: flume
Updated Branches:
  refs/heads/trunk 35cf90001 -> 72b54c990


FLUME-2472. SyslogUtils fails when system locale is not English

(Santiago M. Mola via Hari)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/72b54c99
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/72b54c99
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/72b54c99

Branch: refs/heads/trunk
Commit: 72b54c9909290fa5b98123b4b0c1332a425c5c64
Parents: 35cf900
Author: Hari Shreedharan <hshreedharan@apache.org>
Authored: Thu Oct 9 23:17:30 2014 -0700
Committer: Hari Shreedharan <hshreedharan@apache.org>
Committed: Thu Oct 9 23:18:12 2014 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/flume/source/SyslogUtils.java   | 11 ++++++-----
 .../java/org/apache/flume/source/TestSyslogUtils.java    |  3 ++-
 2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/72b54c99/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java b/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java
index 208fefe..43f8db0 100644
--- a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java
+++ b/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java
@@ -36,6 +36,7 @@ import java.util.Calendar;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.MatchResult;
@@ -240,10 +241,10 @@ public class SyslogUtils {
     // timezone in RFC5424 is [+-]tt:tt, so remove the ':' for java date formatting
     fmt1.searchPattern.add("([+-])(\\d{2})[:](\\d{2})");
     fmt1.replacePattern.add("$1$2$3");
-    fmt1.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC5424_1));
-    fmt1.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC5424_2));
-    fmt1.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC5424_3));
-    fmt1.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC5424_4));
+    fmt1.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC5424_1, Locale.ENGLISH));
+    fmt1.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC5424_2, Locale.ENGLISH));
+    fmt1.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC5424_3, Locale.ENGLISH));
+    fmt1.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC5424_4, Locale.ENGLISH));
     fmt1.addYear = false;
 
     // setup RFC3164 formater
@@ -252,7 +253,7 @@ public class SyslogUtils {
     // the single digit date has two spaces, so trim it
     fmt2.searchPattern.add("  ");
     fmt2.replacePattern.add(" ");
-    fmt2.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC3164_1));
+    fmt2.dateFormat.add(new SimpleDateFormat(SYSLOG_TIMESTAMP_FORMAT_RFC3164_1, Locale.ENGLISH));
     fmt2.addYear = true;
 
     formats.add(fmt1);

http://git-wip-us.apache.org/repos/asf/flume/blob/72b54c99/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java b/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java
index 76ee5b1..86ef40f 100644
--- a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java
+++ b/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java
@@ -29,6 +29,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.HashSet;
+import java.util.Locale;
 import java.util.Map;
 
 public class TestSyslogUtils {
@@ -184,7 +185,7 @@ public class TestSyslogUtils {
     if (stamp1 == null) {
       Assert.assertFalse(headers2.containsKey("timestamp"));
     } else {
-      SimpleDateFormat formater = new SimpleDateFormat(format1);
+      SimpleDateFormat formater = new SimpleDateFormat(format1, Locale.ENGLISH);
       Assert.assertEquals(String.valueOf(formater.parse(stamp1).getTime()), headers2.get("timestamp"));
     }
     if (host1 == null) {


Mime
View raw message