[Red5commits] [1633] modified patch applied for APPSERVER-27: transient fields are not serialized at

jbauch luke at codegent.com
Wed Jan 24 11:10:34 EST 2007


modified patch applied for APPSERVER-27: transient fields are not serialized at all


Timestamp: 01/18/07 18:46:51 EST (6 days ago) 
Change: 1633 
Author: jbauch

Files (see diff or trac for details): 
java/server/trunk/src/org/red5/io/object/Serializer.java


Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1633

Index: /java/server/trunk/src/org/red5/io/object/Serializer.java
===================================================================
--- /java/server/trunk/src/org/red5/io/object/Serializer.java (revision 1608)
+++ /java/server/trunk/src/org/red5/io/object/Serializer.java (revision 1633)
@@ -29,4 +29,5 @@
 import java.lang.reflect.Array;
 import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.util.*;
 
@@ -487,4 +488,5 @@
 		Iterator it = set.iterator();
         // Iterate thru entries and write out property names with separators
+		Class beanClass = bean.getClass();
         while (it.hasNext()) {
 			BeanMap.Entry entry = (BeanMap.Entry) it.next();
@@ -493,6 +495,21 @@
 			}
 
-			out.writePropertyName(entry.getKey().toString());
-			//log.info(entry.getKey().toString()+" = "+entry.getValue());
+			String keyName = entry.getKey().toString();
+			// Check if the Field corresponding to the getter/setter pair is transient
+			try {
+				Field field = beanClass.getDeclaredField(keyName);
+				int modifiers = field.getModifiers();
+				
+				if (Modifier.isTransient(modifiers)) {
+					if (log.isDebugEnabled()) {
+						log.debug("Skipping " + field.getName() + " because its transient");
+					}
+					continue;
+				}
+			} catch (NoSuchFieldException nfe) {
+				// Ignore this exception and use the default behaviour
+			}
+			
+			out.writePropertyName(keyName);
 			serialize(out, entry.getValue());
 			if (it.hasNext()) {


Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.



More information about the Red5commits mailing list