Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 1981 invoked from network); 28 Jul 2009 11:10:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jul 2009 11:10:01 -0000 Received: (qmail 15886 invoked by uid 500); 28 Jul 2009 11:11:18 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 15864 invoked by uid 500); 28 Jul 2009 11:11:18 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 15854 invoked by uid 99); 28 Jul 2009 11:11:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 11:11:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 11:11:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4009C23888E2; Tue, 28 Jul 2009 11:10:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r798486 - in /harmony/enhanced/classlib/trunk/modules/math/src: main/java/java/math/Multiplication.java test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java Date: Tue, 28 Jul 2009 11:10:56 -0000 To: commits@harmony.apache.org From: hindessm@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090728111056.4009C23888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hindessm Date: Tue Jul 28 11:10:55 2009 New Revision: 798486 URL: http://svn.apache.org/viewvc?rev=798486&view=rev Log: Applied patch from "[#HARMONY-6271] [classlib][math] BigDecimal.divide should throw an ArithmeticException instead of OutOfMemory for too large scales". Modified: harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java Modified: harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java?rev=798486&r1=798485&r2=798486&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java (original) +++ harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java Tue Jul 28 11:10:55 2009 @@ -440,7 +440,7 @@ if (byteArraySize > Runtime.getRuntime().freeMemory()) { // math.01=power of ten too big - throw new OutOfMemoryError(Messages.getString("math.01")); //$NON-NLS-1$ + throw new ArithmeticException(Messages.getString("math.01")); //$NON-NLS-1$ } if (exp <= Integer.MAX_VALUE) { // To calculate: 5^exp * 2^exp Modified: harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java?rev=798486&r1=798485&r2=798486&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java Tue Jul 28 11:10:55 2009 @@ -1287,6 +1287,24 @@ assertEquals("incorrect scale", resScale, result.scale()); } + + /** + * BigDecimal.divide with a scale that's too large + * + * Regression test for HARMONY-6271 + */ + public void testDivideLargeScale() { + BigDecimal arg1 = new BigDecimal("320.0E+2147483647"); + BigDecimal arg2 = new BigDecimal("6E-2147483647"); + try { + BigDecimal result = arg1.divide(arg2, Integer.MAX_VALUE, + java.math.RoundingMode.CEILING); + fail("Expected ArithmeticException when dividing with a scale that's too large"); + } catch (ArithmeticException e) { + // expected behaviour + } + } + /** * divideToIntegralValue(BigDecimal) */