Skip to content

google-cloud-java: generated gRPC/Proto files fails lint #7146

Description

@zhumin8

Observed lint failures in
googleapis/google-cloud-java#13928
googleapis/google-cloud-java#13929
However, on the onboarding PR lint did not fail: https://github.com/googleapis/google-cloud-java/pull/13864/changes
(different issue CI is bypassing grpc-* modules for lint - https://github.com/googleapis/google-cloud-java/blob/bfd98cf1b68f706c9847baa86908b196697eaa0c/.kokoro/build.sh#L263)

Several generated gRPC files (e.g., SqlEventsServiceGrpc.java, SqlAvailableDatabaseVersionsServiceGrpc.java) were found to have formatting violations (specifically, extra vertical whitespace between the package declaration and the class Javadoc). These files were generated by Librarian and should have been formatted, but they remained unformatted in the final output.

Root Cause Analysis

  1. Empty Services in Cloud SQL: The Cloud SQL API defines several services (like SqlEventsService and SqlAvailableDatabaseVersionsService) that have zero methods generated in their gRPC stubs.
  2. Unused Import Generation: The gRPC Java generator (protoc-gen-grpc-java) blindly prepends import static io.grpc.MethodDescriptor.generateFullMethodName; to all generated service files, which makes it unused in these empty services.
  3. google-java-format Bug: When GJF (tested on 1.25.2 and the latest 1.35.0) removes this unused import, it fails to collapse the vertical whitespace in the same pass, leaving extra empty lines in the file.

workaround: Running GJF a second time collapses these lines and fixes the formatting. But every invoke of GJF needs starting a new Java Virtual Machine (JVM) instance. Implementing this workaround would add to already long generating time (estimate ~5-10mins for all)

more in thread

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions