Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 27372 invoked from network); 21 Jul 2005 18:18:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Jul 2005 18:18:06 -0000 Received: (qmail 38644 invoked by uid 500); 21 Jul 2005 18:18:02 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 38572 invoked by uid 500); 21 Jul 2005 18:18:02 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 38559 invoked by uid 99); 21 Jul 2005 18:18:02 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jul 2005 11:17:53 -0700 Received: by ajax.apache.org (Postfix, from userid 99) id 219D7D2; Thu, 21 Jul 2005 20:17:49 +0200 (CEST) From: bugzilla@apache.org To: commons-dev@jakarta.apache.org Subject: DO NOT REPLY [Bug 35804] - [configuration] Make Configuration Serializable X-Bugzilla-Reason: AssignedTo Message-Id: <20050721181749.219D7D2@ajax.apache.org> Date: Thu, 21 Jul 2005 20:17:49 +0200 (CEST) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND� INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=35804 ------- Additional Comments From ebourg@apache.org 2005-07-21 20:17 ------- This is not as trivial as I thought initially... I made FileConfiguration extends Serializable and wrote a test case serializing a PropertiesConfiguration to a file. This led me to the following changes: - make ReloadingStrategy extend Serializable as well - change the type of the reloadLock in AbtractFileConfiguration to something else than Object that is serializable. I picked String. I tried to make it transient, but it resulted in a NullPointerException when accessing the deserialized configuration because it was not initialized. I tried to move the initialization in the no arg constructor but it didn't work, I'm not sure to understand why this constructor isn't called when the deserialized instance is build. It still failed after these changes, because the deserialized configuration was actually empty. It appears that the Map in BaseConfiguration is not serialized. I put a similar Map in AbstractFileConfiguration and it got serialized property, but by simply moving this Map to BaseConfiguration it disappeared from the serialized file, I have no idea why. I tested with the JDK 1.4.2_08. Here is the test added to TestPropertiesConfiguration: public void testSerialization() throws Exception { // remove the previous serialization file File file = new File("target/configuration.ser"); if (file.exists()) { file.delete(); } // write the configuration to the configuration.ser file ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file)); out.writeObject(conf); out.close(); // load the configuration from the file ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); PropertiesConfiguration conf2 = (PropertiesConfiguration) in.readObject(); in.close(); // check the deserialized configuration assertNotNull("deserialized configuration null", conf2); assertEquals("filename", conf.getFileName(), conf2.getFileName()); assertEquals("basepath", conf.getBasePath(), conf2.getBasePath()); assertEquals("header", conf.getHeader(), conf2.getHeader()); assertFalse("deserialized configuration empty", conf2.isEmpty()); Iterator keys = conf.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); assertTrue("missing key from the deserialized configuration : " + key, conf2.containsKey(key)); assertEquals("wrong value in the deserialized configuration for the key " + key, conf.getProperty(key), conf2.getProperty(key)); } } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org