commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1557598 - in /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2: BasicDataSource.java BasicDataSourceFactory.java datasources/InstanceKeyDataSource.java
Date Sun, 12 Jan 2014 19:01:01 GMT
Author: markt
Date: Sun Jan 12 19:01:00 2014
New Revision: 1557598

URL: http://svn.apache.org/r1557598
Log:
Reduce FindBugs warnings
Explicitly define the encoding to use rather than depending on the defaults

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1557598&r1=1557597&r2=1557598&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java Sun Jan
12 19:01:00 2014
@@ -16,8 +16,10 @@
  */
 package org.apache.commons.dbcp2;
 
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.lang.management.ManagementFactory;
+import java.nio.charset.StandardCharsets;
 import java.util.Properties;
 import java.util.Collection;
 import java.util.List;
@@ -1289,7 +1291,8 @@ public class BasicDataSource
     /**
      * The PrintWriter to which log messages should be directed.
      */
-    protected PrintWriter logWriter = new PrintWriter(System.out);
+    protected PrintWriter logWriter = new PrintWriter(new OutputStreamWriter(
+            System.out, StandardCharsets.UTF_8));
 
 
     // ----------------------------------------------------- DataSource Methods

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java?rev=1557598&r1=1557597&r2=1557598&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
Sun Jan 12 19:01:00 2014
@@ -18,6 +18,7 @@
 package org.apache.commons.dbcp2;
 
 import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
 import java.sql.Connection;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -393,7 +394,7 @@ public class BasicDataSourceFactory impl
         if (value != null) {
             dataSource.setJmxName(value);
         }
-        
+
         // DBCP-215
         // Trick to make sure that initialSize connections are created
         if (dataSource.getInitialSize() > 0) {
@@ -413,7 +414,8 @@ public class BasicDataSourceFactory impl
     static private Properties getProperties(String propText) throws Exception {
       Properties p = new Properties();
       if (propText != null) {
-        p.load(new ByteArrayInputStream(propText.replace(';', '\n').getBytes()));
+        p.load(new ByteArrayInputStream(
+                propText.replace(';', '\n').getBytes(StandardCharsets.ISO_8859_1)));
       }
       return p;
     }

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java?rev=1557598&r1=1557597&r2=1557598&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
Sun Jan 12 19:01:00 2014
@@ -17,8 +17,10 @@
 
 package org.apache.commons.dbcp2.datasources;
 
+import java.io.OutputStreamWriter;
 import java.io.Serializable;
 import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
@@ -369,7 +371,7 @@ public abstract class InstanceKeyDataSou
     protected String getInstanceKey() {
         return instanceKey;
     }
-    
+
     /**
      * Get the value of jndiEnvironment which is used when instantiating
      * a jndi InitialContext.  This InitialContext is used to locate the
@@ -399,7 +401,7 @@ public abstract class InstanceKeyDataSou
         }
         jndiEnvironment.setProperty(key, value);
     }
-    
+
     /**
      * Sets the JNDI environment to be used when instantiating a JNDI
      * InitialContext. This InitialContext is used to locate the backend
@@ -442,7 +444,8 @@ public abstract class InstanceKeyDataSou
     @Override
     public PrintWriter getLogWriter() {
         if (logWriter == null) {
-            logWriter = new PrintWriter(System.out);
+            logWriter = new PrintWriter(
+                    new OutputStreamWriter(System.out, StandardCharsets.UTF_8));
         }
         return logWriter;
     }



Mime
View raw message