directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1199700 - /directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java
Date Wed, 09 Nov 2011 11:35:25 GMT
Author: elecharny
Date: Wed Nov  9 11:35:24 2011
New Revision: 1199700

URL: http://svn.apache.org/viewvc?rev=1199700&view=rev
Log:
Fix a failing test with the latest JVM version on mac (1.6.0_29).

This is absolutely ugly : the name of a private field for the sun.security.krb5.KrbKdcReq
class has changed from udpPrefLimit to defaultUdpPrefLimit, leading to a NoSuchFieldException
when we try to fetch this field to change its value. I don't know why we try to modify this
value, but in any case, the resulting failure is just expected.

I don't know if it's possible to avoid such usage of reflection o get the same result, but
if so, we must absolutely avoid accessing inner fields of classes we don't own ...

Modified:
    directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java

Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java?rev=1199700&r1=1199699&r2=1199700&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java
(original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java
Wed Nov  9 11:35:24 2011
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertEqu
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.util.Collections;
 
 import javax.security.auth.Subject;
@@ -210,7 +211,19 @@ public class AbstractKerberosITest exten
     {
         String clazz = "sun.security.krb5.KrbKdcReq";
         Class<?> krbKdcReqClass = Class.forName( clazz );
-        Field udpPrefLimitField = krbKdcReqClass.getDeclaredField( "udpPrefLimit" );
+        
+        // Absolutely ugly fix to get this method working with the latest JVM on Mac (1.6.0_29)
+        Field udpPrefLimitField = null;
+        
+        try
+        { 
+        	udpPrefLimitField = krbKdcReqClass.getDeclaredField( "udpPrefLimit" );
+        }
+        catch ( NoSuchFieldException nsfe )
+        {
+        	udpPrefLimitField = krbKdcReqClass.getDeclaredField( "defaultUdpPrefLimit" );
+        }
+        
         udpPrefLimitField.setAccessible( true );
         return udpPrefLimitField;
     }



Mime
View raw message