Skip to content

Commit

Permalink
[Java][Dataflow Runner] Add precondition to make sure userAgent name …
Browse files Browse the repository at this point in the history
…and version are not empty (#29157)
  • Loading branch information
andreigurau authored Oct 27, 2023
1 parent 919441e commit 71a74b9
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,14 @@ && isServiceEndpoint(dataflowOptions.getDataflowEndpoint())) {
}

DataflowRunnerInfo dataflowRunnerInfo = DataflowRunnerInfo.getDataflowRunnerInfo();
String userAgentName = dataflowRunnerInfo.getName();
Preconditions.checkArgument(
!userAgentName.equals(""), "Dataflow runner's `name` property cannot be empty.");
String userAgentVersion = dataflowRunnerInfo.getVersion();
Preconditions.checkArgument(
!userAgentVersion.equals(""), "Dataflow runner's `version` property cannot be empty.");
String userAgent =
String.format(
"%s/%s%s",
dataflowRunnerInfo.getName(), dataflowRunnerInfo.getVersion(), agentJavaVer)
.replace(" ", "_");
String.format("%s/%s%s", userAgentName, userAgentVersion, agentJavaVer).replace(" ", "_");
dataflowOptions.setUserAgent(userAgent);

return new DataflowRunner(dataflowOptions);
Expand Down

0 comments on commit 71a74b9

Please sign in to comment.