Skip to content

Commit 2ee0ee7

Browse files
authored
fix: include kalix_policy.proto even if source info is disabled (#1152)
1 parent fedc857 commit 2ee0ee7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

sdk/java-sdk/src/main/scala/kalix/javasdk/impl/DiscoveryImpl.scala

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class DiscoveryImpl(system: ActorSystem, services: Map[String, Service], sdkName
9595
val grpcClients = GrpcClients(system)
9696
// pass the deployed name of the service on to GrpcClients for cross component calls
9797
if (in.internalProxyHostname.isEmpty) {
98-
// for backward compatibiliy with proxy 1.0.14 or older
98+
// for backward compatibility with proxy 1.0.14 or older
9999
grpcClients.setProxyHostname(in.proxyHostname)
100100
} else {
101101
grpcClients.setProxyHostname(in.internalProxyHostname)
@@ -250,10 +250,17 @@ class DiscoveryImpl(system: ActorSystem, services: Map[String, Service], sdkName
250250
object DiscoveryImpl {
251251

252252
private[impl] def fileDescriptorSet(services: Iterable[Service], userDescPath: String, log: Logger) = {
253-
val descriptorsWithSource = loadDescriptorsWithSource(userDescPath, log)
253+
254+
val descriptors = loadFileDescriptors(userDescPath, log)
255+
254256
val allDescriptors =
255257
AnySupport.flattenDescriptors(services.flatMap(s => s.descriptor.getFile +: s.additionalDescriptors).toSeq)
258+
256259
val builder = DescriptorProtos.FileDescriptorSet.newBuilder()
260+
261+
val descriptorsWithSource = descriptors.filter { case (_, proto) =>
262+
proto.hasSourceCodeInfo
263+
}
257264
allDescriptors.values.foreach { fd =>
258265
val proto = fd.toProto
259266
// We still use the descriptor as passed in by the user, but if we have one that we've read from the
@@ -264,16 +271,14 @@ object DiscoveryImpl {
264271
builder.addFile(protoWithSource)
265272
}
266273
// include 'kalix_policy.proto' with ACL defaults for entire Kalix service if the file exists
267-
descriptorsWithSource
274+
descriptors
268275
.collect { case (file, proto) if file.endsWith("kalix_policy.proto") => proto }
269276
.foreach(defaultPolicy => builder.addFile(defaultPolicy))
270277

271278
builder.build()
272279
}
273280

274-
private[impl] def loadDescriptorsWithSource(
275-
path: String,
276-
log: Logger): Map[String, DescriptorProtos.FileDescriptorProto] =
281+
private[impl] def loadFileDescriptors(path: String, log: Logger): Map[String, DescriptorProtos.FileDescriptorProto] =
277282
// Special case for disabled, this allows the user to disable attempting to load the descriptor, which means
278283
// they won't get the great big warning below if it doesn't exist.
279284
if (path == "disabled") {
@@ -307,9 +312,7 @@ object DiscoveryImpl {
307312
.parseFrom(stream)
308313
.getFileList
309314
.asScala
310-
.collect {
311-
case file if file.hasSourceCodeInfo => file.getName -> file
312-
}
315+
.map { case file => file.getName -> file }
313316
.toMap
314317
} catch {
315318
case NonFatal(e) =>

0 commit comments

Comments
 (0)