From 86dbeafda2f29dc77730b8532f5ca1f930f8a208 Mon Sep 17 00:00:00 2001 From: Ulrik Sandberg Date: Sun, 20 Dec 2009 12:44:15 +0000 Subject: [PATCH] Now uses Java5 constructor only if at least JDK15 (LDAP-196). --- .../ldap/core/support/DefaultDirObjectFactory.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/core/support/DefaultDirObjectFactory.java b/core/src/main/java/org/springframework/ldap/core/support/DefaultDirObjectFactory.java index 3aeb8a3d..ca4bdf58 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/DefaultDirObjectFactory.java +++ b/core/src/main/java/org/springframework/ldap/core/support/DefaultDirObjectFactory.java @@ -28,6 +28,7 @@ import javax.naming.spi.DirObjectFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.JdkVersion; import org.springframework.ldap.core.DirContextAdapter; import org.springframework.ldap.core.DistinguishedName; import org.springframework.ldap.support.LdapUtils; @@ -153,8 +154,17 @@ public class DefaultDirObjectFactory implements DirObjectFactory { nameString = pathString; } catch (URISyntaxException e) { - throw new IllegalArgumentException("Supplied name starts with protocol prefix indicating a referral," - + " but is not possible to parse to an URI", e); + if (JdkVersion.isAtLeastJava15()) { + throw new IllegalArgumentException( + "Supplied name starts with protocol prefix indicating a referral," + + " but is not possible to parse to an URI", + e); + } else { + throw new IllegalArgumentException( + "Supplied name starts with protocol prefix indicating a referral," + + " but is not possible to parse to an URI: " + + e.getMessage()); + } } if (log.isDebugEnabled()) { log.debug("Resulting name after removal of referral information: '" + nameString + "'");