@@ -541,23 +541,12 @@ boolean hasAnyExternallyManagedInitMethod(String initMethod) {
541
541
if (isExternallyManagedInitMethod (initMethod )) {
542
542
return true ;
543
543
}
544
- if (this .externallyManagedInitMethods != null ) {
545
- for (String candidate : this .externallyManagedInitMethods ) {
546
- int indexOfDot = candidate .lastIndexOf ('.' );
547
- if (indexOfDot >= 0 ) {
548
- String methodName = candidate .substring (indexOfDot + 1 );
549
- if (methodName .equals (initMethod )) {
550
- return true ;
551
- }
552
- }
553
- }
554
- }
555
- return false ;
544
+ return hasAnyExternallyManagedMethod (this .externallyManagedInitMethods , initMethod );
556
545
}
557
546
}
558
547
559
548
/**
560
- * Return all externally managed initialization methods (as an immutable Set).
549
+ * Get all externally managed initialization methods (as an immutable Set).
561
550
* <p>See {@link #registerExternallyManagedInitMethod} for details
562
551
* regarding the format for the initialization methods in the returned set.
563
552
* @since 5.3.11
@@ -627,19 +616,23 @@ boolean hasAnyExternallyManagedDestroyMethod(String destroyMethod) {
627
616
if (isExternallyManagedDestroyMethod (destroyMethod )) {
628
617
return true ;
629
618
}
630
- if (this .externallyManagedDestroyMethods != null ) {
631
- for (String candidate : this .externallyManagedDestroyMethods ) {
632
- int indexOfDot = candidate .lastIndexOf ('.' );
633
- if (indexOfDot >= 0 ) {
634
- String methodName = candidate .substring (indexOfDot + 1 );
635
- if (methodName .equals (destroyMethod )) {
636
- return true ;
637
- }
619
+ return hasAnyExternallyManagedMethod (this .externallyManagedDestroyMethods , destroyMethod );
620
+ }
621
+ }
622
+
623
+ private static boolean hasAnyExternallyManagedMethod (Set <String > candidates , String methodName ) {
624
+ if (candidates != null ) {
625
+ for (String candidate : candidates ) {
626
+ int indexOfDot = candidate .lastIndexOf ('.' );
627
+ if (indexOfDot > 0 ) {
628
+ String candidateMethodName = candidate .substring (indexOfDot + 1 );
629
+ if (candidateMethodName .equals (methodName )) {
630
+ return true ;
638
631
}
639
632
}
640
633
}
641
- return false ;
642
634
}
635
+ return false ;
643
636
}
644
637
645
638
/**
0 commit comments