logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r1602570 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j: chainsaw/vfs/VFSLogFilePatternReceiver.java varia/LogFilePatternReceiver.java
Date Sat, 14 Jun 2014 08:10:14 GMT
Author: sdeboy
Date: Sat Jun 14 08:10:13 2014
New Revision: 1602570

URL: http://svn.apache.org/r1602570
Log:
Use UTF-8 encoding for VFS/LogFilePatternReceiver readers

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java?rev=1602570&r1=1602569&r2=1602570&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java
Sat Jun 14 08:10:13 2014
@@ -29,6 +29,7 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.io.UnsupportedEncodingException;
 
 import javax.swing.JButton;
 import javax.swing.JDialog;
@@ -356,7 +357,7 @@ public class VFSLogFilePatternReceiver e
 
                     fileObject = fileSystemManager.resolveFile(getFileURL(), opts);
                     if (fileObject.exists()) {
-                        reader = new InputStreamReader(fileObject.getContent().getInputStream());
+                        reader = new InputStreamReader(fileObject.getContent().getInputStream()
, "UTF-8");
                         //now that we have a reader, remove additional portions of the file
url (sftp passwords, etc.)
                         //check to see if the name is a URLFileName..if so, set file name
to not include username/pass
                         if (fileObject.getName() instanceof URLFileName) {
@@ -369,6 +370,8 @@ public class VFSLogFilePatternReceiver e
                     }
                 } catch (FileSystemException fse) {
                     getLogger().info(loggableFileURL + " not available - may be due to incorrect
credentials, but will re-attempt to load after waiting " + MISSING_FILE_RETRY_MILLIS + " millis",
fse);
+                } catch (UnsupportedEncodingException e) {
+                    getLogger().info("UTF-8 not available", e);
                 }
                 if (reader == null) {
                     synchronized (this) {
@@ -419,7 +422,7 @@ public class VFSLogFilePatternReceiver e
                             }
                             //could have been truncated or appended to (don't do anything
if same size)
                             if (fileObject.getContent().getSize() < lastFileSize) {
-                                reader = new InputStreamReader(fileObject.getContent().getInputStream());
+                                reader = new InputStreamReader(fileObject.getContent().getInputStream(),
"UTF-8");
                                 getLogger().debug(getPath() + " was truncated");
                                 lastFileSize = 0; //seek to beginning of file
                                 lastFilePointer = 0;
@@ -427,7 +430,7 @@ public class VFSLogFilePatternReceiver e
                                 fileLarger = true;
                                 RandomAccessContent rac = fileObject.getContent().getRandomAccessContent(RandomAccessMode.READ);
                                 rac.seek(lastFilePointer);
-                                reader = new InputStreamReader(rac.getInputStream());
+                                reader = new InputStreamReader(rac.getInputStream(), "UTF-8");
                                 BufferedReader bufferedReader = new BufferedReader(reader);
                                 process(bufferedReader);
                                 lastFilePointer = rac.getFilePointer();

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java?rev=1602570&r1=1602569&r2=1602570&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
Sat Jun 14 08:10:13 2014
@@ -1046,7 +1046,7 @@ public class LogFilePatternReceiver exte
             while (reader == null) {
                 getLogger().info("attempting to load file: " + getFileURL());
                 try {
-                    reader = new InputStreamReader(new URL(getFileURL()).openStream());
+                    reader = new InputStreamReader(new URL(getFileURL()).openStream(), "UTF-8");
                 } catch (FileNotFoundException fnfe) {
                     getLogger().info("file not available - will try again");
                     synchronized (this) {



Mime
View raw message