db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1032481 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/Cursor.java testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java testing/org/apache/derbyTesting/system/oe/client/Submitter.java
Date Mon, 08 Nov 2010 08:01:39 GMT
Author: kahatlen
Date: Mon Nov  8 08:01:39 2010
New Revision: 1032481

URL: http://svn.apache.org/viewvc?rev=1032481&view=rev
Log:
DERBY-4892: Unsafe use of BigDecimal constructors

Use BigDecimal.valueOf(long), which is available on all supported
platforms.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java?rev=1032481&r1=1032480&r2=1032481&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java Mon Nov  8 08:01:39
2010
@@ -971,7 +971,7 @@ public abstract class Cursor {
     final java.math.BigDecimal getBigDecimal(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
         case java.sql.Types.BOOLEAN:
-            return new java.math.BigDecimal( getInt( column ) );
+            return java.math.BigDecimal.valueOf(getLong(column));
         case java.sql.Types.DECIMAL:
             return get_DECIMAL(column);
         case java.sql.Types.REAL:

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java?rev=1032481&r1=1032480&r2=1032481&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
Mon Nov  8 08:01:39 2010
@@ -46,7 +46,7 @@ public class Price implements Externaliz
     public Timestamp timeInstant;
 
     // methods to be registered as functions
-    public static Price makePrice( ) { return new Price( "USD", new BigDecimal( 1 ), DEFAULT_TIMESTAMP
); }
+    public static Price makePrice( ) { return new Price( "USD", BigDecimal.valueOf(1L), DEFAULT_TIMESTAMP
); }
     public static Price makePrice( String currencyCode, BigDecimal amount, Timestamp timeInstant
) { return new Price( currencyCode, amount, timeInstant ); }
     public static String getCurrencyCode( Price price ) { return price.currencyCode; }
     public static BigDecimal getAmount( Price price ) { return price.amount; }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java?rev=1032481&r1=1032480&r2=1032481&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java
Mon Nov  8 08:01:39 2010
@@ -530,8 +530,8 @@ public class Submitter {
     
     private String percent(int count, int total)
     {
-        BigDecimal c = new BigDecimal((long) count * 100L);
-        BigDecimal t = new BigDecimal((long) total);
+        BigDecimal c = BigDecimal.valueOf((long) count * 100L);
+        BigDecimal t = BigDecimal.valueOf((long) total);
         
         BigDecimal p = c.divide(t, 2, BigDecimal.ROUND_DOWN);
         



Mime
View raw message