db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess PersistentFieldPropertyImpl.java PersistentFieldDefaultImpl.java
Date Fri, 20 Dec 2002 21:49:00 GMT
mattbaird    2002/12/20 13:49:00

  Modified:    src/java/org/apache/ojb/broker/metadata/fieldaccess
                        PersistentFieldPropertyImpl.java
                        PersistentFieldDefaultImpl.java
  Log:
  fix for PersistentFieldPropertyImpl so we can null out references that aren't primitives
  
  Revision  Changes    Path
  1.5       +18 -13    jakarta-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldPropertyImpl.java
  
  Index: PersistentFieldPropertyImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldPropertyImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PersistentFieldPropertyImpl.java	20 Dec 2002 01:53:31 -0000	1.4
  +++ PersistentFieldPropertyImpl.java	20 Dec 2002 21:49:00 -0000	1.5
  @@ -54,16 +54,16 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.ojb.broker.metadata.MetadataException;
  +import org.apache.ojb.broker.util.logging.Logger;
  +import org.apache.ojb.broker.util.logging.LoggerFactory;
  +
   import java.beans.BeanInfo;
   import java.beans.IntrospectionException;
   import java.beans.Introspector;
   import java.beans.PropertyDescriptor;
   import java.lang.reflect.Method;
   
  -import org.apache.ojb.broker.metadata.MetadataException;
  -import org.apache.ojb.broker.util.logging.Logger;
  -import org.apache.ojb.broker.util.logging.LoggerFactory;
  -
   /**
    * Access Fileds using Properties
    * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
  @@ -98,20 +98,25 @@
   	{
   		Method m = getPropertyDescriptor().getWriteMethod();
   		Object[] args = { aValue };
  -
   		if (m != null)
   		{
  -			if (aValue != null)
  +			try
   			{
  -				try
  +				/**
  +				 * MBAIRD: it is safe to call getParameterTypes()[0] because this is
  +				 * the "set" method and it needs to take one parameter only.
  +				 * we need to be able to set values to null. We can only set something to null if
  +				 * the type is not a primitive (assignable from Object).
  +				 */
  +				if ((aValue != null) || !m.getParameterTypes()[0].isPrimitive())
   				{
   					m.invoke(anObject, args);
   				}
  -				catch (Throwable e)
  -				{
  -					logProblem(anObject, aValue, e.getClass().getName());
  -					throw new MetadataException("Error invoking method:" + m.getName() + " in object:"
+ anObject.getClass().getName(), e);
  -				}
  +			}
  +			catch (Throwable e)
  +			{
  +				logProblem(anObject, aValue, e.getClass().getName());
  +				throw new MetadataException("Error invoking method:" + m.getName() + " in object:"
+ anObject.getClass().getName(), e);
   			}
   		}
   		else
  
  
  
  1.13      +3 -3      jakarta-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDefaultImpl.java
  
  Index: PersistentFieldDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDefaultImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PersistentFieldDefaultImpl.java	20 Dec 2002 01:53:32 -0000	1.12
  +++ PersistentFieldDefaultImpl.java	20 Dec 2002 21:49:00 -0000	1.13
  @@ -124,9 +124,9 @@
   	 */
   	public synchronized void set(Object obj, Object value) throws MetadataException
   	{
  -		boolean before = getField().isAccessible();
  -		AccessController.doPrivileged(setAccessibleAction);
   		Field f = getField();
  +		boolean before = f.isAccessible();
  +		AccessController.doPrivileged(setAccessibleAction);
   		Class type = f.getType();
   		/**
   		 * MBAIRD
  
  
  

Mime
View raw message