Skip to content

Commit 5668041

Browse files
authored
Fixing spring (#2116)
[utbot-spring] Making process specific arguments as lambda
1 parent 246bea2 commit 5668041

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/process/AbstractRDProcessCompanion.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ import kotlin.io.path.pathString
99
abstract class AbstractRDProcessCompanion(
1010
private val debugPort: Int,
1111
private val runWithDebug: Boolean,
12-
private val suspendExecutionInDebugMode: Boolean
12+
private val suspendExecutionInDebugMode: Boolean,
13+
private val processSpecificCommandLineArgs: () -> List<String>
1314
) {
1415
private val javaExecutablePathString get() =
1516
JdkInfoService.provide().path.resolve("bin${File.separatorChar}${osSpecificJavaExecutable()}")
1617

17-
protected abstract fun obtainProcessSpecificCommandLineArgs(): List<String>
18-
1918
protected fun obtainProcessCommandLine(port: Int): List<String> = buildList {
2019
addAll(obtainCommonProcessCommandLineArgs())
21-
addAll(obtainProcessSpecificCommandLineArgs())
20+
addAll(processSpecificCommandLineArgs())
2221
add(rdPortArgument(port))
2322
}
2423

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/rd/InstrumentedProcess.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,17 @@ class InstrumentedProcess private constructor(
9595
companion object : AbstractRDProcessCompanion(
9696
debugPort = UtSettings.instrumentedProcessDebugPort,
9797
runWithDebug = UtSettings.runInstrumentedProcessWithDebug,
98-
suspendExecutionInDebugMode = UtSettings.suspendInstrumentedProcessExecutionInDebugMode
99-
) {
100-
override fun obtainProcessSpecificCommandLineArgs(): List<String> = buildList {
101-
add("-javaagent:${instrumentationJarFile.path}")
102-
add("-ea")
103-
add("-jar")
104-
add(instrumentationJarFile.path)
105-
if (!UtSettings.useSandbox)
106-
add(DISABLE_SANDBOX_OPTION)
107-
}
98+
suspendExecutionInDebugMode = UtSettings.suspendInstrumentedProcessExecutionInDebugMode,
99+
processSpecificCommandLineArgs = {
100+
buildList {
101+
add("-javaagent:${instrumentationJarFile.path}")
102+
add("-ea")
103+
add("-jar")
104+
add(instrumentationJarFile.path)
105+
if (!UtSettings.useSandbox)
106+
add(DISABLE_SANDBOX_OPTION)
107+
}
108+
}) {
108109

109110
suspend operator fun <TIResult, TInstrumentation : Instrumentation<TIResult>> invoke(
110111
parent: Lifetime,

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ class EngineProcess private constructor(val project: Project, private val classN
100100
companion object : AbstractRDProcessCompanion(
101101
debugPort = UtSettings.engineProcessDebugPort,
102102
runWithDebug = UtSettings.runEngineProcessWithDebug,
103-
suspendExecutionInDebugMode = UtSettings.suspendEngineProcessExecutionInDebugMode
103+
suspendExecutionInDebugMode = UtSettings.suspendEngineProcessExecutionInDebugMode,
104+
processSpecificCommandLineArgs = { listOf("-ea", log4j2ConfigSwitch, "-cp", pluginClasspath, startFileName) }
104105
) {
105-
override fun obtainProcessSpecificCommandLineArgs(): List<String> =
106-
listOf("-ea", log4j2ConfigSwitch, "-cp", pluginClasspath, startFileName)
107-
108106
fun createBlocking(project: Project, classNameToPath: Map<String, String?>): EngineProcess = runBlocking { EngineProcess(project, classNameToPath) }
109107

110108
suspend operator fun invoke(project: Project, classNameToPath: Map<String, String?>): EngineProcess =

utbot-spring-analyzer/src/main/kotlin/org/utbot/spring/process/SpringAnalyzerProcess.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ class SpringAnalyzerProcess private constructor(
6161
companion object : AbstractRDProcessCompanion(
6262
debugPort = UtSettings.springAnalyzerProcessDebugPort,
6363
runWithDebug = UtSettings.runSpringAnalyzerProcessWithDebug,
64-
suspendExecutionInDebugMode = UtSettings.suspendSpringAnalyzerProcessExecutionInDebugMode
65-
) {
66-
override fun obtainProcessSpecificCommandLineArgs(): List<String> = listOf(
67-
"-Dorg.apache.commons.logging.LogFactory=org.utbot.spring.loggers.RDApacheCommonsLogFactory",
68-
"-jar",
69-
springAnalyzerJarFile.path
70-
)
64+
suspendExecutionInDebugMode = UtSettings.suspendSpringAnalyzerProcessExecutionInDebugMode,
65+
processSpecificCommandLineArgs = {
66+
listOf(
67+
"-Dorg.apache.commons.logging.LogFactory=org.utbot.spring.loggers.RDApacheCommonsLogFactory",
68+
"-jar",
69+
springAnalyzerJarFile.path
70+
)
71+
}) {
7172

7273
fun createBlocking() = runBlocking { SpringAnalyzerProcess() }
7374

0 commit comments

Comments
 (0)