This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

extending DirContextAdapter

Feb 4th, 2007, 06:36 AM

Hi,
I would like to post spring-ldap team my extension of DirContextAdapter.
When item in the ldap is not set, method context.getStringAttribute throw
exception NullPointerException. In practise application is it obstruction.

When getStringAttribute throw exception, method get default value. You can
get other the string values such as double,boolean, long, int.

This code may behave only for new implementation of DirContextAdapter.

Comment

Hi rasky,
when attribute exist in ldap, such as itbNN but not set ( has no value ), it throw NullPointerException. When you can get any value from ldap and value not set, you would like set default value and its code repetition. When you can get numeric value or logic value, its the same problem.

Comment

Well, I still don't understand. Could you please send me the stacktrace of the NullPointerException, so that I can pinpoint the exact line where it occurs?

Hi, problem is at user.setUid(context.getStringAttributes("uid")); line. But this reason is well for other operations. When property not set, you get default value and you get concrete data type and don't have to retype each accessed attribute.

I go to simulate this problem and at next reply I copy complete stack.