GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(types): Use fully-qualified message type names [ggj] by miraleung · Pull Request #723 · googleapis/sdk-platform-java

This repository was archived by the owner on Oct 29, 2026. It is now read-only.

Conversation

@miraleung

@miraleung miraleung commented May 11, 2021

Copy link
Copy Markdown
Contributor

Addresses the use case where a proto message foo.bar.Car has an internal field with the same short name, such as bar.foo.Car.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@miraleung
fix(types): Use fully-qualified message type names
836a45f
@miraleung
miraleung requested a review from a team May 11, 2021 20:09
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label May 11, 2021
@miraleung
miraleung requested a review from vam-google May 11, 2021 20:09
@codecov

codecov Bot commented May 11, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Merging #723 (13c92e1) into master (2318136) will decrease coverage by 0.19%.
The diff coverage is 79.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #723      +/-   ##
==========================================
- Coverage   92.52%   92.33%   -0.20%     
==========================================
  Files         124      124              
  Lines       13459    13489      +30     
  Branches      981      994      +13     
==========================================
+ Hits        12453    12455       +2     
- Misses        765      784      +19     
- Partials      241      250       +9     
Impacted Files Coverage Δ
...rator/gapic/composer/ServiceStubClassComposer.java 99.18% <ø> (-0.01%) ⬇️
.../com/google/api/generator/gapic/model/Message.java 80.76% <ø> (-11.54%) ⬇️
...pic/composer/ServiceStubSettingsClassComposer.java 99.10% <50.00%> (+0.07%) ⬆️
...google/api/generator/gapic/protoparser/Parser.java 48.06% <65.11%> (+0.36%) ⬆️
...gapic/composer/ServiceClientTestClassComposer.java 89.60% <90.90%> (ø)
...tor/gapic/composer/BatchingDescriptorComposer.java 99.73% <100.00%> (ø)
...tor/gapic/composer/ServiceClientClassComposer.java 98.45% <100.00%> (-0.01%) ⬇️
...ic/composer/defaultvalue/DefaultValueComposer.java 92.09% <100.00%> (ø)
...er/samplecode/ServiceClientSampleCodeComposer.java 99.28% <100.00%> (+<0.01%) ⬆️
...pi/generator/gapic/protoparser/HttpRuleParser.java 90.76% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2318136...13c92e1. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vam-google
vam-google approved these changes May 13, 2021
View reviewed changes

@vam-google vam-google left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with few minor comments, please address those before submitting

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/com/google/api/generator/gapic/model/Message.java
public abstract String name();

// The fully-qualified proto name, which differs from the Java fully-qualified name.
public abstract String fullProtoName();

@vam-google vam-google May 13, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please specify how exactly they are different? Is it about the extra com. prefix for java names, or more than that?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@miraleung miraleung May 13, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's the proto package versus the java_package. Added an example.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/com/google/api/generator/gapic/protoparser/Parser.java Outdated
// These can be short names (e.g. FooMessage) or fully-qualified names with the *proto* package.
String responseTypeName = lroInfo.getResponseType();
String metadataTypeName = lroInfo.getMetadataType();
String[] responseTypeNameComponents = responseTypeName.split("\\.");

@vam-google vam-google May 13, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but it seems like you don't need the full set of compontents, only the last element after dot, so it can be something like.

String responseTypeShortName = responseTypeName.substring(responseTypeName.lastIndexOf(".") + 1)

It is not about performance, mainly just to make it clear that the other compnents are not needed to the readers of the code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@miraleung miraleung May 13, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. FWIW, the tradeoff here is an extra check that the index is >= 0.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/com/google/api/generator/gapic/protoparser/Parser.java Outdated
// The messageTypes map keys to the Java fully-qualified name.
for (Map.Entry<String, Message> messageEntry : messageTypes.entrySet()) {
String[] packageComponents = messageEntry.getKey().split("\\.");
String messageShortName = packageComponents[packageComponents.length - 1];

@vam-google vam-google May 13, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar situation as with responseTypeShortName and metadataTypeShortName

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@miraleung miraleung May 13, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/com/google/api/generator/gapic/protoparser/Parser.java
for (Map.Entry<String, Message> messageEntry : messageTypes.entrySet()) {
String[] packageComponents = messageEntry.getKey().split("\\.");
String messageShortName = packageComponents[packageComponents.length - 1];
if (responseMessage == null) {

@vam-google vam-google May 13, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The responseMessage logic and metadataMessage logic seem to be a copypaste of each other. Please consider moving that into a private or method combining this to a for loop with 2 elements in it (response and metadata messages).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@miraleung miraleung May 13, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd considered using these, which would result in the following tradeoffs:

  • Nested loop: Need an extra map or data structure to associate responseMessage, responseTypeName, isResponseTypeNameShortOnly, which would be less readable, or recompute the latter in the loop (which is inefficient).
  • Separate method: Need to take four parameters at best - the three above plus messageEntry, which would make the call site, helper signature, and method itself less readable.

Given that the logic is relatively small, copy-pasting does not seem to have significantly better or worse tradeoffs compared to the alternative approches.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@miraleung
fix: cleanup
13c92e1
@miraleung
miraleung merged commit 8a5c36c into master May 13, 2021
@miraleung
miraleung deleted the dev/full_msg_types branch May 13, 2021 22:21
@miraleung miraleung mentioned this pull request May 14, 2021
fix(types): Reorder nested types for legacy protos w/ java_outer_class in one file [ggj] #724
Merged
suztomo pushed a commit that referenced this pull request Mar 21, 2023
@gcf-owl-bot
chore: update dependencies for regapic (#1467) (#723)
be8b69d
* chore: update dependencies for regapic

* add more dependencies and trigger comment

* update goldens

* fix indentation

* remove duplicate gax-httpjson dependency

* remove duplicated dependencies
Source-Link: googleapis/synthtool@fa54eb2
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906
suztomo pushed a commit that referenced this pull request Mar 21, 2023
@renovate-bot
build(deps): update dependency org.apache.maven.plugins:maven-javadoc…
501fd7b
…-plugin to v3.3.2 (#723)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.apache.maven.plugins:maven-javadoc-plugin](https://maven.apache.org/plugins/) | `3.3.1` -> `3.3.2` | [![age](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-javadoc-plugin/3.3.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-javadoc-plugin/3.3.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-javadoc-plugin/3.3.2/compatibility-slim/3.3.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-javadoc-plugin/3.3.2/confidence-slim/3.3.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-core).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@vam-google vam-google vam-google approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@miraleung @vam-google
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.