Skip to content

Commit 0113d17

Browse files
johnynekittaiz
authored andcommitted
Fix issue with empty args and workers (#245)
Fix issue with empty args and workers
1 parent 59fadb8 commit 0113d17

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/scala/scripts/TwitterScroogeGenerator.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,20 @@ class ScroogeGenerator extends Processor {
4040
}
4141

4242
def processRequest(args: java.util.List[String]) {
43-
def getIdx(i: Int): List[String] =
44-
if (args.size > i) args.get(i).split(':').toList.filter(_.nonEmpty)
43+
def getIdx(i: Int): List[String] = {
44+
if (args.size > i) {
45+
// bazel worker arguments cannot be empty so we pad to ensure non-empty
46+
// and drop it off on the other side
47+
// https://github.com/bazelbuild/bazel/issues/3329
48+
val workerArgPadLen = 1 // workerArgPadLen == "_".length
49+
args.get(i)
50+
.drop(workerArgPadLen)
51+
.split(':')
52+
.toList
53+
.filter(_.nonEmpty)
54+
}
4555
else Nil
56+
}
4657

4758
val jarOutput = args.get(0)
4859
// These are the files whose output we want

twitter_scrooge/twitter_scrooge.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ def _gen_scrooge_srcjar_impl(ctx):
140140
# in order to generate code) have targets which will compile them.
141141
_assert_set_is_subset(only_transitive_thrift_srcs, transitive_owned_srcs)
142142

143-
path_content = "\n".join([_colon_paths(ps) for ps in [immediate_thrift_srcs, only_transitive_thrift_srcs, remote_jars, external_jars]])
143+
# bazel worker arguments cannot be empty so we pad to ensure non-empty
144+
# and drop it off on the other side
145+
# https://github.com/bazelbuild/bazel/issues/3329
146+
worker_arg_pad = "_"
147+
path_content = "\n".join([worker_arg_pad + _colon_paths(ps) for ps in [immediate_thrift_srcs, only_transitive_thrift_srcs, remote_jars, external_jars]])
144148
worker_content = "{output}\n{paths}\n".format(output = ctx.outputs.srcjar.path, paths = path_content)
145149

146150
argfile = ctx.new_file(ctx.outputs.srcjar, "%s_worker_input" % ctx.label.name)

0 commit comments

Comments
 (0)