Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f26d423

Browse files
Make obtaining Spring beans a little more safe (#2110)
1 parent 6c76c65 commit f26d423

File tree

1 file changed

+13
-4
lines changed
  • utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api

1 file changed

+13
-4
lines changed

‎utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,10 +1276,19 @@ class SpringApplicationContext(
12761276
private val springInjectedClasses: Set<ClassId>
12771277
get() {
12781278
if (!areInjectedClassesInitialized) {
1279-
springInjectedClassesStorage += beanQualifiedNames
1280-
.map { fqn -> utContext.classLoader.loadClass(fqn) }
1281-
.filterNot { it.isAbstract || it.isInterface || it.isLocalClass || it.isMemberClass && !it.isStatic }
1282-
.mapTo(mutableSetOf()) { it.id }
1279+
for (beanFqn in beanQualifiedNames) {
1280+
try {
1281+
val beanClass = utContext.classLoader.loadClass(beanFqn)
1282+
if (!beanClass.isAbstract && !beanClass.isInterface &&
1283+
!beanClass.isLocalClass && (!beanClass.isMemberClass || beanClass.isStatic)) {
1284+
springInjectedClassesStorage += beanClass.id
1285+
}
1286+
} catch (e: ClassNotFoundException) {
1287+
// For some Spring beans (e.g. with anonymous classes)
1288+
// it is possible to have problems with classes loading.
1289+
continue
1290+
}
1291+
}
12831292

12841293
// This is done to be sure that this storage is not empty after the first class loading iteration.
12851294
// So, even if all loaded classes were filtered out, we will not try to load them again.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /