Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make use of ImmutableMap.Builder#buildOrThrow graceful #2159

Merged
merged 1 commit into from Aug 10, 2023

Conversation

BenWhitehead
Copy link
Collaborator

buildOrThrow was added in guava 31.0, and while we specify a min version >= 31.0, sometimes our library is used in environments that set different guava version (usually due to platform pinned versions).

We do not strictly need this method, as it has the same behavior of ImmutableMap.Builder#build() but with a more clear name (ImmutableMap.Builder never allowed duplicate keys).

Manually tested, but creating a separate project that did the following in its maven config:

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>24.0-jre</version>
      </dependency>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-storage-bom</artifactId>
        <version>2.26.1-SNAPSHOT</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-storage</artifactId>
      <exclusions>
        <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>

Then issuing any RPC.

`buildOrThrow` was added in guava 31.0, and while we specify a min
version >= 31.0, sometimes our library is used in environments that set
different guava version (usually due to platform pinned versions).

We do not strictly need this method, as it has the same behavior of
`ImmutableMap.Builder#build()` but with a more clear name
(`ImmutableMap.Builder` never allowed duplicate keys).

Manually tested, but creating a separate project that did the following
in its maven config:
```
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>24.0-jre</version>
      </dependency>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-storage-bom</artifactId>
        <version>2.26.1-SNAPSHOT</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-storage</artifactId>
      <exclusions>
        <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
```

Then issuing any RPC.
@BenWhitehead BenWhitehead added the owlbot:ignore instruct owl-bot to ignore a PR label Aug 9, 2023
@BenWhitehead BenWhitehead requested a review from a team as a code owner August 9, 2023 20:27
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: storage Issues related to the googleapis/java-storage API. labels Aug 9, 2023
@BenWhitehead BenWhitehead merged commit e9746f8 into main Aug 10, 2023
18 checks passed
@BenWhitehead BenWhitehead deleted the guava-gracefulness branch August 10, 2023 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. owlbot:ignore instruct owl-bot to ignore a PR size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants