Author: rpopma
Date: Fri May 10 15:40:30 2013
New Revision: 1481061
URL: http://svn.apache.org/r1481061
Log:
findbugs fixes: be explicit about desired character encoding
Modified:
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueReceiver.java
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicReceiver.java
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/SocketServer.java
Modified:
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java?rev=1481061&r1=1481060&r2=1481061&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
(original)
+++
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
Fri May 10 15:40:30 2013
@@ -40,6 +40,7 @@ import java.io.InputStream;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -101,7 +102,8 @@ public class JSONConfiguration extends B
} else {
try {
final File destFile =
FileUtils.fileFromURI(new URI(dest));
- stream = new PrintStream(new
FileOutputStream(destFile));
+ final String enc =
Charset.defaultCharset().name();
+ stream = new PrintStream(new
FileOutputStream(destFile), true, enc);
} catch (final URISyntaxException use) {
System.err.println("Unable to write to " +
dest + ". Writing to stdout");
}
@@ -226,7 +228,7 @@ public class JSONConfiguration extends B
}
private Node constructNode(final String name, final Node parent, final
JsonNode jsonNode) {
- final PluginType type = getPluginManager().getPluginType(name);
+ final PluginType<?> type = getPluginManager().getPluginType(name);
final Node node = new Node(parent, name, type);
processAttributes(node, jsonNode);
final Iterator<Map.Entry<String, JsonNode>> iter =
jsonNode.getFields();
@@ -242,7 +244,7 @@ public class JSONConfiguration extends B
LOGGER.debug("Processing node for array " +
entry.getKey());
for (int i = 0; i < n.size(); ++i) {
final String pluginType = getType(n.get(i),
entry.getKey());
- final PluginType entryType =
getPluginManager().getPluginType(pluginType);
+ final PluginType<?> entryType =
getPluginManager().getPluginType(pluginType);
final Node item = new Node(node, entry.getKey(),
entryType);
processAttributes(item, n.get(i));
if (pluginType.equals(entry.getKey())) {
Modified:
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java?rev=1481061&r1=1481060&r2=1481061&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
(original)
+++
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
Fri May 10 15:40:30 2013
@@ -54,6 +54,7 @@ import java.io.InputStream;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -121,7 +122,8 @@ public class XMLConfiguration extends Ba
} else {
try {
final File destFile =
FileUtils.fileFromURI(new URI(dest));
- stream = new PrintStream(new
FileOutputStream(destFile));
+ final String enc =
Charset.defaultCharset().name();
+ stream = new PrintStream(new
FileOutputStream(destFile), true, enc);
} catch (final URISyntaxException use) {
System.err.println("Unable to write to " +
dest + ". Writing to stdout");
}
@@ -290,7 +292,7 @@ public class XMLConfiguration extends Ba
if (w3cNode instanceof Element) {
final Element child = (Element) w3cNode;
final String name = getType(child);
- final PluginType type = getPluginManager().getPluginType(name);
+ final PluginType<?> type =
getPluginManager().getPluginType(name);
final Node childNode = new Node(node, name, type);
constructHierarchy(childNode, child);
if (type == null) {
Modified:
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueReceiver.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueReceiver.java?rev=1481061&r1=1481060&r2=1481061&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueReceiver.java
(original)
+++
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueReceiver.java
Fri May 10 15:40:30 2013
@@ -28,6 +28,7 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
+import java.nio.charset.Charset;
/**
* Receives Log Events over a JMS Queue. This implementation expects that all
messages will
@@ -81,7 +82,8 @@ public class JMSQueueReceiver extends Ab
new JMSQueueReceiver(qcfBindingName, queueBindingName, username,
password);
- final BufferedReader stdin = new BufferedReader(new
InputStreamReader(System.in));
+ final Charset enc = Charset.defaultCharset();
+ final BufferedReader stdin = new BufferedReader(new
InputStreamReader(System.in, enc));
// Loop until the word "exit" is typed
System.out.println("Type \"exit\" to quit JMSQueueReceiver.");
while (true) {
Modified:
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicReceiver.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicReceiver.java?rev=1481061&r1=1481060&r2=1481061&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicReceiver.java
(original)
+++
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicReceiver.java
Fri May 10 15:40:30 2013
@@ -28,6 +28,7 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
+import java.nio.charset.Charset;
/**
* Receives Topic messages that contain LogEvents. This implementation expects
that all messages
@@ -80,7 +81,8 @@ public class JMSTopicReceiver extends Ab
new JMSTopicReceiver(tcfBindingName, topicBindingName, username,
password);
- final BufferedReader stdin = new BufferedReader(new
InputStreamReader(System.in));
+ final Charset enc = Charset.defaultCharset();
+ final BufferedReader stdin = new BufferedReader(new
InputStreamReader(System.in, enc));
// Loop until the word "exit" is typed
System.out.println("Type \"exit\" to quit JMSTopicReceiver.");
while (true) {
Modified:
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/SocketServer.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/SocketServer.java?rev=1481061&r1=1481060&r2=1481061&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/SocketServer.java
(original)
+++
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/SocketServer.java
Fri May 10 15:40:30 2013
@@ -38,6 +38,7 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.net.URI;
import java.net.URL;
+import java.nio.charset.Charset;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -93,7 +94,8 @@ public class SocketServer extends Abstra
final SocketServer sserver = new SocketServer(port);
final Thread server = new Thread(sserver);
server.start();
- final BufferedReader reader = new BufferedReader(new
InputStreamReader(System.in));
+ final Charset enc = Charset.defaultCharset();
+ final BufferedReader reader = new BufferedReader(new
InputStreamReader(System.in, enc));
while (true) {
final String line = reader.readLine();
if (line.equalsIgnoreCase("Quit") || line.equalsIgnoreCase("Stop")
|| line.equalsIgnoreCase("Exit")) {