Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5112ea0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "ProtoLogTool: Fix thread pool leak on code generation exception"

parents 8ee531e9 1d75e9c9
Loading
Loading
Loading
Loading
+46 −42
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ object ProtoLogTool {

        val executor = newThreadPool()

        try {
            command.javaSourceArgs.map { path ->
                executor.submitCallable {
                    val transformer = SourceTransformer(command.protoLogImplClassNameArg,
@@ -67,8 +68,8 @@ object ProtoLogTool {
                            text
                        }
                    } catch (ex: ParsingException) {
                    // If we cannot parse this file, skip it (and log why). Compilation will fail
                    // in a subsequent build step.
                        // If we cannot parse this file, skip it (and log why). Compilation will
                        // fail in a subsequent build step.
                        injector.reportParseError(ex)
                        text
                    }
@@ -80,8 +81,9 @@ object ProtoLogTool {
                outJar.write(outSrc.toByteArray())
                outJar.closeEntry()
            }

        } finally {
            executor.shutdown()
        }

        val cacheSplit = command.protoLogCacheClassNameArg.split(".")
        val cacheName = cacheSplit.last()
@@ -153,6 +155,7 @@ ${updates.replaceIndent(" ")}

        val executor = newThreadPool()

        try {
            command.javaSourceArgs.map { path ->
                executor.submitCallable {
                    val file = File(path)
@@ -162,8 +165,8 @@ ${updates.replaceIndent(" ")}
                            val code = tryParse(text, path)
                            builder.findLogCalls(code, path, packagePath(file, code))
                        } catch (ex: ParsingException) {
                        // If we cannot parse this file, skip it (and log why). Compilation will fail
                        // in a subsequent build step.
                            // If we cannot parse this file, skip it (and log why). Compilation will
                            // fail in a subsequent build step.
                            injector.reportParseError(ex)
                            null
                        }
@@ -174,8 +177,9 @@ ${updates.replaceIndent(" ")}
            }.forEach { future ->
                builder.addLogCalls(future.get() ?: return@forEach)
            }

        } finally {
            executor.shutdown()
        }

        val out = injector.fileOutputStream(command.viewerConfigJsonArg)
        out.write(builder.build().toByteArray())