You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2006/11/11 02:45:45 UTC
svn commit: r473624 - in /geronimo/server/trunk/modules/geronimo-kernel/src:
main/java/org/apache/geronimo/gbean/ test/data/gbeaninfo/
test/java/org/apache/geronimo/gbean/
Author: gdamour
Date: Fri Nov 10 17:45:44 2006
New Revision: 473624
URL: http://svn.apache.org/viewvc?view=rev&rev=473624
Log:
Fix a backward compatibility problem with GBeanInfo that I have not identified (thanks David J. for spotting it).
Added:
geronimo/server/trunk/modules/geronimo-kernel/src/test/data/gbeaninfo/
geronimo/server/trunk/modules/geronimo-kernel/src/test/data/gbeaninfo/SERIALIZATION_-6198804067155550221.ser (with props)
Modified:
geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java
Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java?view=diff&rev=473624&r1=473623&r2=473624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java Fri Nov 10 17:45:44 2006
@@ -17,18 +17,20 @@
package org.apache.geronimo.gbean;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
import java.util.Map;
-import java.util.HashMap;
-import java.util.Arrays;
+import java.util.Set;
import org.apache.geronimo.kernel.management.NotificationType;
@@ -38,7 +40,8 @@
* @version $Rev$ $Date$
*/
public final class GBeanInfo implements Serializable {
-
+ private static final long serialVersionUID = -6198804067155550221L;
+
public static final int PRIORITY_CLASSLOADER = 1;
public static final int PRIORITY_NORMAL = 5;
@@ -95,7 +98,7 @@
private final Set references;
private final Map referencesByName;
private final Set interfaces;
- private final int priority;
+ private int priority;
/**
* @deprecated use GBeanInfoBuilder
@@ -275,6 +278,11 @@
return priority;
}
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ priority = GBeanInfo.PRIORITY_NORMAL;
+ in.defaultReadObject();
+ }
+
public String toString() {
StringBuffer result = new StringBuffer("[GBeanInfo:");
result.append(" id=").append(super.toString());
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/data/gbeaninfo/SERIALIZATION_-6198804067155550221.ser
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/data/gbeaninfo/SERIALIZATION_-6198804067155550221.ser?view=auto&rev=473624
==============================================================================
Binary file - no diff available.
Propchange: geronimo/server/trunk/modules/geronimo-kernel/src/test/data/gbeaninfo/SERIALIZATION_-6198804067155550221.ser
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java?view=diff&rev=473624&r1=473623&r2=473624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java Fri Nov 10 17:45:44 2006
@@ -17,15 +17,20 @@
package org.apache.geronimo.gbean;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
+import org.apache.geronimo.testsupport.TestSupport;
/**
* @version $Rev$ $Date$
*/
-public class GBeanInfoTest extends TestCase {
+public class GBeanInfoTest extends TestSupport {
private static final String CONSTRUCTOR_ARG_0 = "ConstructorArg_0";
private static final String CONSTRUCTOR_ARG_1 = "ConstructorArg_1";
@@ -96,6 +101,26 @@
assertEquals(gbeanInfo.toString(), MockGBean.getGBeanInfo().toString());
}
+ public void testBackwardCompatibility() throws Exception {
+ FileInputStream fis = new FileInputStream(resolveFile("src/test/data/gbeaninfo/SERIALIZATION_-6198804067155550221.ser"));
+ ObjectInputStream is = new ObjectInputStream(fis);
+ GBeanInfo beanInfo = (GBeanInfo) is.readObject();
+ assertEquals(GBeanInfo.PRIORITY_NORMAL, beanInfo.getPriority());
+ }
+
+ public void testCurrentSerialization() throws Exception {
+ GBeanInfo beanInfo = MockGBean.GBEAN_INFO;
+
+ ByteArrayOutputStream memOut = new ByteArrayOutputStream();
+ ObjectOutputStream os = new ObjectOutputStream(memOut);
+ os.writeObject(beanInfo);
+
+ ByteArrayInputStream memIn = new ByteArrayInputStream(memOut.toByteArray());
+ ObjectInputStream is = new ObjectInputStream(memIn);
+ beanInfo = (GBeanInfo) is.readObject();
+ assertEquals(GBeanInfo.PRIORITY_CLASSLOADER, beanInfo.getPriority());
+ }
+
GBeanInfo gbeanInfo;
final static String nonPersistentAttrName = "nonPersistentAttribute";
@@ -135,6 +160,7 @@
infoFactory.addAttribute(CONSTRUCTOR_ARG_0, String.class, true);
infoFactory.addAttribute(CONSTRUCTOR_ARG_1, String.class, true);
+ infoFactory.setPriority(GBeanInfo.PRIORITY_CLASSLOADER);
infoFactory.setConstructor(new String[]{CONSTRUCTOR_ARG_0, CONSTRUCTOR_ARG_1});