Skip to content

Commit f691859

Browse files
reid-spencerclaude
andcommitted
Fix sbt-riddl process I/O to avoid pipe-close exceptions
Replace ProcessLogger + .!() with ProcessIO + BasicIO.processFully to properly drain stdout/stderr before waiting for exit. Prevents unsightly exceptions when subprocess streams close during termination. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2f09a2d commit f691859

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

sbt-riddl/src/main/scala/com/ossuminc/riddl/sbt/plugin/RiddlSbtPlugin.scala

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,19 @@ object RiddlSbtPlugin extends AutoPlugin {
300300
log.info(s"Running: riddlc ${args.mkString(" ")}")
301301
val errOutput = new StringBuilder
302302
val outOutput = new StringBuilder
303-
val logger = ProcessLogger(
304-
out => { outOutput.append(out).append("\n"); () },
305-
err => { errOutput.append(err).append("\n"); () }
306-
)
307-
val exitCode = Process(
303+
val proc = Process(
308304
binary.getAbsolutePath +: (globalOptions ++ args),
309305
workDir
310-
).!(logger)
306+
).run(new ProcessIO(
307+
_.close(),
308+
BasicIO.processFully { out =>
309+
outOutput.append(out).append("\n"); ()
310+
},
311+
BasicIO.processFully { err =>
312+
errOutput.append(err).append("\n"); ()
313+
}
314+
))
315+
val exitCode = proc.exitValue()
311316

312317
// Log output
313318
val out = outOutput.toString.trim
@@ -348,14 +353,19 @@ object RiddlSbtPlugin extends AutoPlugin {
348353
val args = argsBuilder(conf)
349354
val errBuf = new StringBuilder
350355
val outBuf = new StringBuilder
351-
val pLogger = ProcessLogger(
352-
out => { outBuf.append(out).append("\n"); () },
353-
err => { errBuf.append(err).append("\n"); () }
354-
)
355-
val exitCode = Process(
356+
val proc = Process(
356357
binary.getAbsolutePath +: (globalOptions ++ args),
357358
conf.getParentFile
358-
).!(pLogger)
359+
).run(new ProcessIO(
360+
_.close(),
361+
BasicIO.processFully { out =>
362+
outBuf.append(out).append("\n"); ()
363+
},
364+
BasicIO.processFully { err =>
365+
errBuf.append(err).append("\n"); ()
366+
}
367+
))
368+
val exitCode = proc.exitValue()
359369

360370
if (exitCode != 0) {
361371
val detail =

0 commit comments

Comments
 (0)