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 + "'");