@@ -92,130 +92,133 @@ public static void closeContext(DirContext context) {
9292 public static NamingException convertLdapException (javax .naming .NamingException ex ) {
9393 Assert .notNull (ex , "NamingException must not be null" );
9494
95- if (ex . getClass (). equals ( javax .naming .directory .AttributeInUseException .class )) {
95+ if (javax .naming .directory .AttributeInUseException .class . isAssignableFrom ( ex . getClass () )) {
9696 return new org .springframework .ldap .AttributeInUseException (
9797 (javax .naming .directory .AttributeInUseException ) ex );
9898 }
99- if (ex . getClass (). equals ( javax .naming .directory .AttributeModificationException .class )) {
99+ if (javax .naming .directory .AttributeModificationException .class . isAssignableFrom ( ex . getClass () )) {
100100 return new org .springframework .ldap .AttributeModificationException (
101101 (javax .naming .directory .AttributeModificationException ) ex );
102102 }
103- if (ex . getClass (). equals ( javax .naming .CannotProceedException .class )) {
103+ if (javax .naming .CannotProceedException .class . isAssignableFrom ( ex . getClass () )) {
104104 return new org .springframework .ldap .CannotProceedException ((javax .naming .CannotProceedException ) ex );
105105 }
106- if (ex . getClass (). equals ( javax .naming .CommunicationException .class )) {
106+ if (javax .naming .CommunicationException .class . isAssignableFrom ( ex . getClass () )) {
107107 return new org .springframework .ldap .CommunicationException ((javax .naming .CommunicationException ) ex );
108108 }
109- if (ex . getClass (). equals ( javax .naming .ConfigurationException .class )) {
109+ if (javax .naming .ConfigurationException .class . isAssignableFrom ( ex . getClass () )) {
110110 return new org .springframework .ldap .ConfigurationException ((javax .naming .ConfigurationException ) ex );
111111 }
112- if (ex . getClass (). equals ( javax .naming .ContextNotEmptyException .class )) {
112+ if (javax .naming .ContextNotEmptyException .class . isAssignableFrom ( ex . getClass () )) {
113113 return new org .springframework .ldap .ContextNotEmptyException ((javax .naming .ContextNotEmptyException ) ex );
114114 }
115- if (ex . getClass (). equals ( javax .naming .InsufficientResourcesException .class )) {
115+ if (javax .naming .InsufficientResourcesException .class . isAssignableFrom ( ex . getClass () )) {
116116 return new org .springframework .ldap .InsufficientResourcesException (
117117 (javax .naming .InsufficientResourcesException ) ex );
118118 }
119- if (ex . getClass (). equals ( javax .naming .InterruptedNamingException .class )) {
119+ if (javax .naming .InterruptedNamingException .class . isAssignableFrom ( ex . getClass () )) {
120120 return new org .springframework .ldap .InterruptedNamingException ((javax .naming .InterruptedNamingException ) ex );
121121 }
122- if (ex . getClass (). equals ( javax .naming .directory .InvalidAttributeIdentifierException .class )) {
122+ if (javax .naming .directory .InvalidAttributeIdentifierException .class . isAssignableFrom ( ex . getClass () )) {
123123 return new org .springframework .ldap .InvalidAttributeIdentifierException (
124124 (javax .naming .directory .InvalidAttributeIdentifierException ) ex );
125125 }
126- if (ex . getClass (). equals ( javax .naming .directory .InvalidAttributesException .class )) {
126+ if (javax .naming .directory .InvalidAttributesException .class . isAssignableFrom ( ex . getClass () )) {
127127 return new org .springframework .ldap .InvalidAttributesException (
128128 (javax .naming .directory .InvalidAttributesException ) ex );
129129 }
130- if (ex . getClass (). equals ( javax .naming .directory .InvalidAttributeValueException .class )) {
130+ if (javax .naming .directory .InvalidAttributeValueException .class . isAssignableFrom ( ex . getClass () )) {
131131 return new org .springframework .ldap .InvalidAttributeValueException (
132132 (javax .naming .directory .InvalidAttributeValueException ) ex );
133133 }
134- if (ex . getClass (). equals ( javax .naming .InvalidNameException .class )) {
134+ if (javax .naming .InvalidNameException .class . isAssignableFrom ( ex . getClass () )) {
135135 return new org .springframework .ldap .InvalidNameException ((javax .naming .InvalidNameException ) ex );
136136 }
137- if (ex . getClass (). equals ( javax .naming .directory .InvalidSearchControlsException .class )) {
137+ if (javax .naming .directory .InvalidSearchControlsException .class . isAssignableFrom ( ex . getClass () )) {
138138 return new org .springframework .ldap .InvalidSearchControlsException (
139139 (javax .naming .directory .InvalidSearchControlsException ) ex );
140140 }
141- if (ex . getClass (). equals ( javax .naming .directory .InvalidSearchFilterException .class )) {
141+ if (javax .naming .directory .InvalidSearchFilterException .class . isAssignableFrom ( ex . getClass () )) {
142142 return new org .springframework .ldap .InvalidSearchFilterException (
143143 (javax .naming .directory .InvalidSearchFilterException ) ex );
144144 }
145145
146- // this class is abstract, so it can never be of exactly this class;
147- // using instanceof
148- if (ex instanceof javax .naming .ldap .LdapReferralException ) {
146+ if (javax .naming .ldap .LdapReferralException .class .isAssignableFrom (ex .getClass ())) {
149147 return new org .springframework .ldap .LdapReferralException ((javax .naming .ldap .LdapReferralException ) ex );
150148 }
151- // Skipping the abstract superclass javax.naming.ReferralException
149+
150+ if (javax .naming .ReferralException .class .isAssignableFrom (ex .getClass ())) {
151+ return new org .springframework .ldap .ReferralException ((javax .naming .ReferralException ) ex );
152+ }
152153
153154 // LimitExceededException hierarchy
154- if (ex . getClass (). equals ( javax .naming .SizeLimitExceededException .class )) {
155+ if (javax .naming .SizeLimitExceededException .class . isAssignableFrom ( ex . getClass () )) {
155156 return new org .springframework .ldap .SizeLimitExceededException ((javax .naming .SizeLimitExceededException ) ex );
156157 }
157- if (ex . getClass (). equals ( javax .naming .TimeLimitExceededException .class )) {
158+ if (javax .naming .TimeLimitExceededException .class . isAssignableFrom ( ex . getClass () )) {
158159 return new org .springframework .ldap .TimeLimitExceededException ((javax .naming .TimeLimitExceededException ) ex );
159160 }
160161 // this class is the superclass of the two above
161- if (ex . getClass (). equals ( javax .naming .LimitExceededException .class )) {
162+ if (javax .naming .LimitExceededException .class . isAssignableFrom ( ex . getClass () )) {
162163 return new org .springframework .ldap .LimitExceededException ((javax .naming .LimitExceededException ) ex );
163164 }
164165
165166 // LinkException hierarchy
166- if (ex . getClass (). equals ( javax .naming .LinkLoopException .class )) {
167+ if (javax .naming .LinkLoopException .class . isAssignableFrom ( ex . getClass () )) {
167168 return new org .springframework .ldap .LinkLoopException ((javax .naming .LinkLoopException ) ex );
168169 }
169- if (ex . getClass (). equals ( javax .naming .MalformedLinkException .class )) {
170+ if (javax .naming .MalformedLinkException .class . isAssignableFrom ( ex . getClass () )) {
170171 return new org .springframework .ldap .MalformedLinkException ((javax .naming .MalformedLinkException ) ex );
171172 }
172173 // this class is the superclass of the two above
173- if (ex . getClass (). equals ( javax .naming .LinkException .class )) {
174+ if (javax .naming .LinkException .class . isAssignableFrom ( ex . getClass () )) {
174175 return new org .springframework .ldap .LinkException ((javax .naming .LinkException ) ex );
175176 }
176177
177- if (ex . getClass (). equals ( javax .naming .NameAlreadyBoundException .class )) {
178+ if (javax .naming .NameAlreadyBoundException .class . isAssignableFrom ( ex . getClass () )) {
178179 return new org .springframework .ldap .NameAlreadyBoundException ((javax .naming .NameAlreadyBoundException ) ex );
179180 }
180- if (ex . getClass (). equals ( javax .naming .NameNotFoundException .class )) {
181+ if (javax .naming .NameNotFoundException .class . isAssignableFrom ( ex . getClass () )) {
181182 return new org .springframework .ldap .NameNotFoundException ((javax .naming .NameNotFoundException ) ex );
182183 }
183184
184185 // NamingSecurityException hierarchy
185- if (ex . getClass (). equals ( javax .naming .NoPermissionException .class )) {
186+ if (javax .naming .NoPermissionException .class . isAssignableFrom ( ex . getClass () )) {
186187 return new org .springframework .ldap .NoPermissionException ((javax .naming .NoPermissionException ) ex );
187188 }
188- if (ex . getClass (). equals ( javax .naming .AuthenticationException .class )) {
189+ if (javax .naming .AuthenticationException .class . isAssignableFrom ( ex . getClass () )) {
189190 return new org .springframework .ldap .AuthenticationException ((javax .naming .AuthenticationException ) ex );
190191 }
191- if (ex . getClass (). equals ( javax .naming .AuthenticationNotSupportedException .class )) {
192+ if (javax .naming .AuthenticationNotSupportedException .class . isAssignableFrom ( ex . getClass () )) {
192193 return new org .springframework .ldap .AuthenticationNotSupportedException (
193194 (javax .naming .AuthenticationNotSupportedException ) ex );
194195 }
195- // Skipping the abstract superclass javax.naming.NamingSecurityException
196+ if (javax .naming .NamingSecurityException .class .isAssignableFrom (ex .getClass ())) {
197+ return new org .springframework .ldap .NamingSecurityException ((javax .naming .NamingSecurityException ) ex );
198+ }
196199
197- if (ex . getClass (). equals ( javax .naming .NoInitialContextException .class )) {
200+ if (javax .naming .NoInitialContextException .class . isAssignableFrom ( ex . getClass () )) {
198201 return new org .springframework .ldap .NoInitialContextException ((javax .naming .NoInitialContextException ) ex );
199202 }
200- if (ex . getClass (). equals ( javax .naming .directory .NoSuchAttributeException .class )) {
203+ if (javax .naming .directory .NoSuchAttributeException .class . isAssignableFrom ( ex . getClass () )) {
201204 return new org .springframework .ldap .NoSuchAttributeException (
202205 (javax .naming .directory .NoSuchAttributeException ) ex );
203206 }
204- if (ex . getClass (). equals ( javax .naming .NotContextException .class )) {
207+ if (javax .naming .NotContextException .class . isAssignableFrom ( ex . getClass () )) {
205208 return new org .springframework .ldap .NotContextException ((javax .naming .NotContextException ) ex );
206209 }
207- if (ex . getClass (). equals ( javax .naming .OperationNotSupportedException .class )) {
210+ if (javax .naming .OperationNotSupportedException .class . isAssignableFrom ( ex . getClass () )) {
208211 return new org .springframework .ldap .OperationNotSupportedException (
209212 (javax .naming .OperationNotSupportedException ) ex );
210213 }
211- if (ex . getClass (). equals ( javax .naming .PartialResultException .class )) {
214+ if (javax .naming .PartialResultException .class . isAssignableFrom ( ex . getClass () )) {
212215 return new org .springframework .ldap .PartialResultException ((javax .naming .PartialResultException ) ex );
213216 }
214- if (ex . getClass (). equals ( javax .naming .directory .SchemaViolationException .class )) {
217+ if (javax .naming .directory .SchemaViolationException .class . isAssignableFrom ( ex . getClass () )) {
215218 return new org .springframework .ldap .SchemaViolationException (
216219 (javax .naming .directory .SchemaViolationException ) ex );
217220 }
218- if (ex . getClass (). equals ( javax .naming .ServiceUnavailableException .class )) {
221+ if (javax .naming .ServiceUnavailableException .class . isAssignableFrom ( ex . getClass () )) {
219222 return new org .springframework .ldap .ServiceUnavailableException (
220223 (javax .naming .ServiceUnavailableException ) ex );
221224 }
0 commit comments