Skip to content

Commit 3d929dd

Browse files
committed
Propagate target exception
Closes gh-660
1 parent d9180f0 commit 3d929dd

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

core/src/main/java/org/springframework/ldap/core/support/AbstractTlsDirContextAuthenticationStrategy.java

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2005-2013 the original author or authors.
2+
* Copyright 2005-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,9 +15,12 @@
1515
*/
1616
package org.springframework.ldap.core.support;
1717

18-
import org.springframework.ldap.UncategorizedLdapException;
19-
import org.springframework.ldap.core.DirContextProxy;
20-
import org.springframework.ldap.support.LdapUtils;
18+
import java.io.IOException;
19+
import java.lang.reflect.InvocationHandler;
20+
import java.lang.reflect.InvocationTargetException;
21+
import java.lang.reflect.Method;
22+
import java.lang.reflect.Proxy;
23+
import java.util.Hashtable;
2124

2225
import javax.naming.NamingException;
2326
import javax.naming.directory.DirContext;
@@ -26,11 +29,10 @@
2629
import javax.naming.ldap.StartTlsResponse;
2730
import javax.net.ssl.HostnameVerifier;
2831
import javax.net.ssl.SSLSocketFactory;
29-
import java.io.IOException;
30-
import java.lang.reflect.InvocationHandler;
31-
import java.lang.reflect.Method;
32-
import java.lang.reflect.Proxy;
33-
import java.util.Hashtable;
32+
33+
import org.springframework.ldap.UncategorizedLdapException;
34+
import org.springframework.ldap.core.DirContextProxy;
35+
import org.springframework.ldap.support.LdapUtils;
3436

3537
/**
3638
* Abstract superclass for {@link DirContextAuthenticationStrategy}
@@ -199,7 +201,11 @@ else if (method.getName().equals(GET_TARGET_CONTEXT_METHOD_NAME)) {
199201
return target;
200202
}
201203
else {
202-
return method.invoke(target, args);
204+
try {
205+
return method.invoke(target, args);
206+
} catch (InvocationTargetException ex) {
207+
throw ex.getTargetException();
208+
}
203209
}
204210
}
205211
}

0 commit comments

Comments
 (0)