Skip to content

Commit d26e3d4

Browse files
committed
Remove UtBotSpringShutdownException because it gets caught by Spring
1 parent 1389967 commit d26e3d4

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

utbot-spring-analyzer/src/main/kotlin/org/utbot/spring/analyzers/SpringApplicationAnalyzer.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.utbot.spring.configurators.PropertiesConfigurator
55
import org.utbot.spring.configurators.XmlFilesConfigurator
66
import org.utbot.spring.config.TestApplicationConfiguration
77
import org.springframework.boot.builder.SpringApplicationBuilder
8-
import org.utbot.spring.postProcessors.UtBotSpringShutdownException
8+
import org.springframework.context.ApplicationContextException
99
import org.utbot.spring.utils.ConfigurationManager
1010
import java.net.URL
1111
import java.net.URLClassLoader
@@ -41,10 +41,13 @@ class SpringApplicationAnalyzer(
4141
try {
4242
app.build()
4343
app.run()
44-
} catch (e: UtBotSpringShutdownException) {
44+
} catch (e: ApplicationContextException) {
45+
// UtBotBeanFactoryPostProcessor destroys bean definitions
46+
// to prevent Spring application from actually starting and
47+
// that causes it to throw ApplicationContextException
4548
println("Bean analysis finished successfully")
46-
}finally {
49+
} finally {
4750
fakeFileManager.deleteTempFiles()
4851
}
4952
}
50-
}
53+
}

utbot-spring-analyzer/src/main/kotlin/org/utbot/spring/postProcessors/UtBotBeanFactoryPostProcessor.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class UtBotBeanFactoryPostProcessor : BeanFactoryPostProcessor, PriorityOrdered
2929
destroyBeanDefinitions(beanFactory)
3030

3131
println("Finished post-processing bean factory in UtBot")
32-
throw UtBotSpringShutdownException("Finished post-processing bean factory in UtBot")
3332
}
3433

3534
private fun findBeanClassNames(beanFactory: ConfigurableListableBeanFactory): ArrayList<String> {
@@ -84,4 +83,4 @@ class UtBotBeanFactoryPostProcessor : BeanFactoryPostProcessor, PriorityOrdered
8483
println("Storing bean information failed with exception $e")
8584
}
8685
}
87-
}
86+
}

utbot-spring-analyzer/src/main/kotlin/org/utbot/spring/postProcessors/UtBotSpringShutdownException.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)