Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 58573 invoked from network); 8 Mar 2011 22:52:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Mar 2011 22:52:23 -0000 Received: (qmail 22697 invoked by uid 500); 8 Mar 2011 22:52:23 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 22640 invoked by uid 500); 8 Mar 2011 22:52:22 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 22632 invoked by uid 99); 8 Mar 2011 22:52:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Mar 2011 22:52:22 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_HELO_PASS,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jak-commons-dev@m.gmane.org designates 80.91.229.12 as permitted sender) Received: from [80.91.229.12] (HELO lo.gmane.org) (80.91.229.12) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Mar 2011 22:52:15 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Px5kv-0005D3-1R for dev@commons.apache.org; Tue, 08 Mar 2011 23:51:53 +0100 Received: from hsi-kbw-091-089-186-069.hsi2.kabel-badenwuerttemberg.de ([91.89.186.69]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 08 Mar 2011 23:51:53 +0100 Received: from joerg.schaible by hsi-kbw-091-089-186-069.hsi2.kabel-badenwuerttemberg.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 08 Mar 2011 23:51:53 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: dev@commons.apache.org To: dev@commons.apache.org From: =?UTF-8?B?SsO2cmc=?= Schaible Subject: Re: [math] Re: svn commit: r1078734 Followup-To: gmane.comp.jakarta.commons.devel Date: Tue, 08 Mar 2011 23:51:42 +0100 Lines: 98 Message-ID: References: <20110307103754.1331923889EB@eris.apache.org> <4D768EE6.6050707@free.fr> Reply-To: joerg.schaible@gmx.de Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: hsi-kbw-091-089-186-069.hsi2.kabel-badenwuerttemberg.de Mail-Copies-To: nobody User-Agent: KNode/4.4.9 sebb wrote: > On 8 March 2011 20:17, Luc Maisonobe wrote: >> Le 07/03/2011 11:37, erans@apache.org a écrit : >>> Author: erans >>> Date: Mon Mar 7 10:37:52 2011 >>> New Revision: 1078734 >>> >>> URL: http://svn.apache.org/viewvc?rev=1078734&view=rev >>> Log: >>> MATH-542 >>> "MathRuntimeException" provides two ways for enhancing the information >>> content: one for localized messages and one for storing "context" >>> objects. The additional methods have been added to "MathThrowable". >>> Consequently, dummy implementations were needed in the old >>> "MathRuntimeException" and "MathException". >>> Some parts of the tests for old exceptions were removed as they used >>> methods that were deleted. A call to "MathUserException" in >>> "AbstractContinuousDistribution" was simplified for the same reason. >>> "MathUtils" still contained "String" (instead of "Localizable") as >>> argument to the constructor of a "MathArithmeticException". >>> I don't know why a test in "DummyStepInterpolatorTest" stopped working. >>> It is now commented out; please have a look. >> >> [snip] >> >> >>> Modified: >>> commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java >>> URL: >>> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java?rev=1078734&r1=1078733&r2=1078734&view=diff >>> ============================================================================== >>> --- >>> commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java >>> (original) +++ >>> commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java >>> Mon Mar 7 10:37:52 2011 @@ -123,7 +123,9 @@ public class >>> DummyStepInterpolatorTest { fail("an exception should have been >>> thrown"); } catch (IOException ioe) { // expected behavior - >>> assertEquals(0, ioe.getMessage().length()); + // XXX Why was the >>> message supposed to be empty? + // With the current code it is >>> "org.apache.commons.math.util.Pair". + // assertEquals(0, >>> ioe.getMessage().length()); >> >> The problem here is that the exception thrown which is an IOException >> built from the empty string in the BadStepInterpolator below is not the >> IOException that is caught here. In fact the IOException caught is >> really a java.io.NotSerializableException which is built with the >> message "org.apache.commons.math.util.Pair" automatically by the >> serialization process in the JVM (at least for Oracle implementation). >> >> All exceptions must be serializable (this comes from java.lang.Throwable >> implementing the Serializable interface). This was also one reason why >> our Localizable interface had to extends Serializable, so it could be >> used as a field in our exceptions. >> >> This change added a List> field in >> MathRuntimeException. Pair is not serializable. Adding Serializable to >> the implemented interfaces in Pair does solve the problem (if also the >> change below is reverted, of course) but I don't think it would be wise >> unless we also enforce the two generic parameters of Pair to be >> serializable too. Perhaps we should use a Map >> instead ? >> >> The problem also makes me think that we already had a similar bug in >> another part of the exceptions for a long time : the Object or Object[] >> parameters of the exceptions are stored and may not be Serializable too. >> This was never a problem either because the parameters are often simple >> primitive ones (int, double ...) or arrays so they were serializable. >> Perhaps we should change the signature from Object and Object[] to >> Serializable and Serializable[] ? >> > > Or make the fields transient? > > That would perhaps cause problems if the Exceptions were ever > serialised, but can that happen? Yes, it's a typical JEE scenario and I cannot say how often I cursed Sun for stuffing an unserializable object into NamingException.setResolvedObject within their LDAP implementation ... Actually the MathRE should contain a writeObject implementation that replaces any non-serializable object in that array with some kind of replacement (e.g. with its String representation). Otherwise the MathRE will not reach its destination and all the localization was for nothing. However, with a writeObject/readObject pair, such a field can be made transparent, if the objects are put directly into the object streams. Note, that anything of this requires a change of the serialVersionUID. - Jörg --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org