Skip to content

Commit 2ecbad5

Browse files
committed
Merge branch 'master' of github.com:googleapis/gapic-generator-java into dev/lambda-anon
2 parents 272a04c + c98c0c7 commit 2ecbad5

94 files changed

Lines changed: 4267 additions & 405 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ jobs:
4949
run: bazel --batch test $(bazel query "//src/test/..." | grep "Test$") --noshow_progress --test_output=errors
5050

5151
- name: Integration Tests
52-
# TODO(miraleung): Change this to //test/integration/... after the monolith rule removal.
53-
run: bazel --batch test //test/integration:asset //test/integration:compute //test/integration:credentials //test/integration:iam //test/integration:kms //test/integration:logging //test/integration:pubsub //test/integration:redis //test/integration:library --noshow_progress
54-
55-
- uses: actions/upload-artifact@v2
56-
if: ${{ failure() }}
57-
5852
run: bazel --batch test //test/integration/...
5953

6054
- uses: actions/upload-artifact@v2

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,63 @@
11
# Changelog
22

3+
### [1.0.17](https://www.github.com/googleapis/gapic-generator-java/compare/v1.0.16...v1.0.17) (2021-08-02)
4+
5+
6+
### Features
7+
8+
* **ast:** Add support for multi-catch blocks [ggj] ([#811](https://www.github.com/googleapis/gapic-generator-java/issues/811)) ([55ef1a6](https://www.github.com/googleapis/gapic-generator-java/commit/55ef1a63427683538e48050333eedb0666635568))
9+
* **ast:** Add support for Throwable causes [ggj] ([#801](https://www.github.com/googleapis/gapic-generator-java/issues/801)) ([7fdeece](https://www.github.com/googleapis/gapic-generator-java/commit/7fdeeced7642fefdfdc5c6e898661c72fe9d78a8))
10+
* **ast:** support throwing all kinds of expressions ([#810](https://www.github.com/googleapis/gapic-generator-java/issues/810)) ([0817650](https://www.github.com/googleapis/gapic-generator-java/commit/0817650b35487f32d7987ba718ce71fc7551e3a0))
11+
12+
13+
### Bug Fixes
14+
15+
* (rest transport) Add `@BetaApi` to the generated `TransportServiceFactory` class and lro-specific method ([#787](https://www.github.com/googleapis/gapic-generator-java/issues/787)) ([ebe1aef](https://www.github.com/googleapis/gapic-generator-java/commit/ebe1aefbe860a41aabd8ced5268ccc6c7efdf791))
16+
* prevent hanging by call backgroundResources.close() on stub.close() [ggj] ([#804](https://www.github.com/googleapis/gapic-generator-java/issues/804)) ([428db97](https://www.github.com/googleapis/gapic-generator-java/commit/428db97c1534255a60530a8ed6137efc17ed56f4))
17+
* **resnames:** fallback to fully-qualified Object name upon proto typing conflicts [ggj] ([#803](https://www.github.com/googleapis/gapic-generator-java/issues/803)) ([e654bfb](https://www.github.com/googleapis/gapic-generator-java/commit/e654bfb936b571af2546f550c9a1589f8ad63d67))
18+
19+
20+
21+
### [1.0.16](https://www.github.com/googleapis/gapic-generator-java/compare/v1.0.15...v1.0.16) (2021-06-30)
22+
23+
24+
### Bug Fixes
25+
26+
* **bazel:** Eradicate monolith deps from Java µgen repo ([#778](https://www.github.com/googleapis/gapic-generator-java/issues/778)) ([86f2472](https://www.github.com/googleapis/gapic-generator-java/commit/86f2472963f020127ef6ff92be6241d12e2273af))
27+
* **build:** Update googleapis-discovery hash to fix compute integration test ([#782](https://www.github.com/googleapis/gapic-generator-java/issues/782)) ([46bb19a](https://www.github.com/googleapis/gapic-generator-java/commit/46bb19a7ee61da86b4be6d87a71f3cd210e753d2))
28+
* **protoc:** Mirror protoc's field name conflict resolution logic in client generation ([#781](https://www.github.com/googleapis/gapic-generator-java/issues/781)) ([9432979](https://www.github.com/googleapis/gapic-generator-java/commit/9432979bab59f48c8645fa47d752cdd470d4a682))
29+
30+
### [1.0.15](https://www.github.com/googleapis/gapic-generator-java/compare/v1.0.14...v1.0.15) (2021-06-22)
31+
32+
33+
### Features
34+
35+
* Implement field presence support for DIREGAPIC ([#774](https://www.github.com/googleapis/gapic-generator-java/issues/774)) ([c820361](https://www.github.com/googleapis/gapic-generator-java/commit/c82036105d299b0a1192cd0def5e68253e4f542c))
36+
37+
38+
### Bug Fixes
39+
40+
* **service.yaml:** Remove allowlist restriction ([#776](https://www.github.com/googleapis/gapic-generator-java/issues/776)) ([8f42efd](https://www.github.com/googleapis/gapic-generator-java/commit/8f42efdb92d606a768a524517fe949c4f9112025))
41+
42+
43+
### Miscellaneous Chores
44+
45+
* release 1.0.15 ([f752478](https://www.github.com/googleapis/gapic-generator-java/commit/f75247845344540a94c4efcd416f34f96ea0c2a3))
46+
47+
### [1.0.14](https://www.github.com/googleapis/gapic-generator-java/compare/v1.0.13...v1.0.14) (2021-06-17)
48+
49+
50+
### Features
51+
52+
* Add DIREGAPIC-specific pagination ([#767](https://www.github.com/googleapis/gapic-generator-java/issues/767)) ([1294c29](https://www.github.com/googleapis/gapic-generator-java/commit/1294c298f50cc4474ae562e6a07f37a5f94fe5b8))
53+
54+
55+
### Bug Fixes
56+
57+
* **bazel:** Remove monolith rule deps from the Java µgen Bazel rules ([#764](https://www.github.com/googleapis/gapic-generator-java/issues/764)) ([bff3efc](https://www.github.com/googleapis/gapic-generator-java/commit/bff3efc25e43692ea5b6e769c20d25d5b9a1e3d2))
58+
59+
60+
361
### [1.0.13](https://www.github.com/googleapis/gapic-generator-java/compare/v1.0.12...v1.0.13) (2021-06-16)
462

563

SECURITY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Security Policy
2+
3+
To report a security issue, please use [g.co/vulnz](https://g.co/vulnz).
4+
5+
The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
6+
7+
We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue.

WORKSPACE

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
6969
protobuf_deps()
7070

7171
# Bazel rules.
72-
_rules_gapic_version = "0.5.4"
72+
_rules_gapic_version = "0.5.5"
7373

7474
http_archive(
7575
name = "rules_gapic",
@@ -78,14 +78,6 @@ http_archive(
7878
)
7979

8080
# Java dependencies.
81-
# Import the monolith so we can transitively use its gapic rules for googleapis.
82-
# TODO: Remove this after this dep has been removed from googleapis' switched_rules_by_language.
83-
http_archive(
84-
name = "com_google_api_codegen",
85-
strip_prefix = "gapic-generator-2.11.1",
86-
urls = ["https://github.com/googleapis/gapic-generator/archive/v2.11.1.zip"],
87-
)
88-
8981
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
9082

9183
switched_rules_by_language(

dependencies.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# The properties format is the following:
55
# <dependency_type>[.<artifact_name>]=<value>
66

7-
# Target workspace name: com_google_api_codegen
7+
# Target workspace name: gapic_generator_java
88

99
# Versions only, for dependencies which actual artifacts differ between Bazel and Gradle
1010
version.com_google_protobuf=3.15.8
@@ -32,7 +32,7 @@ maven.org_threeten_threetenbp=org.threeten:threetenbp:1.3.3
3232

3333
# Testing.
3434
maven.junit_junit=junit:junit:4.13.1
35-
# This hamcrest-core dependency is for running JUnit test manually, before JUnit 4.11 it's wrapped along with JUnit package.
35+
# This hamcrest-core dependency is for running JUnit test manually, before JUnit 4.11 it's wrapped along with JUnit package.
3636
# But now it has to be explicitly added.
3737
maven.org_hamcrest_hamcrest_core=org.hamcrest:hamcrest-core:1.3
3838
maven.org_mockito_mockito_core=org.mockito:mockito-core:2.21.0

repositories.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def gapic_generator_java_repositories():
6868
_maybe(
6969
http_archive,
7070
name = "com_google_googleapis_discovery",
71-
strip_prefix = "googleapis-discovery-9b71490900530ce7cb872aabc8e46eac29c1ec37",
71+
strip_prefix = "googleapis-discovery-abf4cec1ce9e02e4d7d650bf66137c347cdd0d44",
7272
urls = [
73-
"https://github.com/googleapis/googleapis-discovery/archive/9b71490900530ce7cb872aabc8e46eac29c1ec37.zip",
73+
"https://github.com/googleapis/googleapis-discovery/archive/abf4cec1ce9e02e4d7d650bf66137c347cdd0d44.zip",
7474
],
7575
)
7676

rules_java_gapic/java_gapic.bzl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
load("@rules_gapic//:gapic.bzl", "proto_custom_library", "unzipped_srcjar")
1616

17-
SERVICE_YAML_ALLOWLIST = ["clouddms", "cloudkms", "datastream", "pubsub"]
1817
NO_GRPC_CONFIG_ALLOWLIST = ["library"]
1918

2019
def _java_gapic_postprocess_srcjar_impl(ctx):
@@ -144,19 +143,8 @@ def _java_gapic_srcjar(
144143
if gapic_yaml:
145144
file_args_dict[gapic_yaml] = "gapic-config"
146145

147-
# Check the allow-list.
148-
# TODO: Open this up after mixins are published, and gate on
149-
# the allowlisted "mixed-in" APIs present in Java.
150146
if service_yaml:
151-
service_yaml_in_allowlist = False
152-
for keyword in SERVICE_YAML_ALLOWLIST:
153-
if keyword in service_yaml:
154-
service_yaml_in_allowlist = True
155-
break
156-
if service_yaml_in_allowlist:
157-
file_args_dict[service_yaml] = "api-service-config"
158-
else:
159-
fail("Service.yaml is no longer supported in the Java microgenerator")
147+
file_args_dict[service_yaml] = "api-service-config"
160148

161149
output_suffix = ".srcjar"
162150
opt_args = []

src/main/java/com/google/api/generator/debug/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_java//java:defs.bzl", "java_library", "java_plugin")
1+
load("@rules_java//java:defs.bzl", "java_library")
22

33
package(default_visibility = ["//visibility:public"])
44

src/main/java/com/google/api/generator/engine/ast/AnnotationNode.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ public void accept(AstNodeVisitor visitor) {
4141
visitor.visit(this);
4242
}
4343

44+
public static AnnotationNode withTypeAndDescription(TypeNode type, String description) {
45+
return AnnotationNode.builder().setType(type).setDescription(description).build();
46+
}
47+
4448
public static AnnotationNode withSuppressWarnings(String description) {
45-
return AnnotationNode.builder()
46-
.setType(annotationType(SuppressWarnings.class))
47-
.setDescription(description)
48-
.build();
49+
return withTypeAndDescription(annotationType(SuppressWarnings.class), description);
4950
}
5051

5152
public static AnnotationNode withType(TypeNode type) {

src/main/java/com/google/api/generator/engine/ast/ThrowExpr.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@
2222
public abstract class ThrowExpr implements Expr {
2323
// TODO(miraleung): Refactor with StringObjectValue and possibly with NewObjectExpr.
2424

25+
@Nullable
26+
public abstract Expr throwExpr();
27+
2528
@Override
2629
public abstract TypeNode type();
2730

2831
@Nullable
2932
public abstract Expr messageExpr();
3033

34+
@Nullable
35+
public abstract Expr causeExpr();
36+
3137
@Override
3238
public void accept(AstNodeVisitor visitor) {
3339
visitor.visit(this);
@@ -39,6 +45,9 @@ public static Builder builder() {
3945

4046
@AutoValue.Builder
4147
public abstract static class Builder {
48+
public abstract Builder setThrowExpr(Expr throwExpr);
49+
50+
// No-op if setThrowExpr is called.
4251
public abstract Builder setType(TypeNode type);
4352

4453
public Builder setMessageExpr(String message) {
@@ -47,22 +56,56 @@ public Builder setMessageExpr(String message) {
4756

4857
public abstract Builder setMessageExpr(Expr expr);
4958

59+
public abstract Builder setCauseExpr(Expr expr);
60+
5061
// Private.
62+
abstract Expr throwExpr();
63+
5164
abstract TypeNode type();
5265

5366
abstract Expr messageExpr();
5467

68+
abstract Expr causeExpr();
69+
5570
abstract ThrowExpr autoBuild();
5671

5772
public ThrowExpr build() {
73+
if (throwExpr() != null) {
74+
setType(throwExpr().type());
75+
Preconditions.checkState(
76+
messageExpr() == null && causeExpr() == null,
77+
"Only one of throwExpr or [messageExpr or causeExpr, inclusive] can be present.");
78+
79+
if (throwExpr() instanceof VariableExpr) {
80+
Preconditions.checkState(
81+
!((VariableExpr) throwExpr()).isDecl(), "Cannot throw a variable declaration");
82+
}
83+
84+
Preconditions.checkState(
85+
TypeNode.isExceptionType(throwExpr().type()),
86+
String.format("Only exception types can be thrown, found %s", throwExpr().type()));
87+
88+
return autoBuild();
89+
}
90+
5891
Preconditions.checkState(
5992
TypeNode.isExceptionType(type()),
6093
String.format("Type %s must be an exception type", type()));
94+
6195
if (messageExpr() != null) {
6296
Preconditions.checkState(
6397
messageExpr().type().equals(TypeNode.STRING),
6498
String.format("Message expression type must be a string for exception %s", type()));
6599
}
100+
101+
if (causeExpr() != null) {
102+
Preconditions.checkState(
103+
TypeNode.THROWABLE.reference().isSupertypeOrEquals(causeExpr().type().reference()),
104+
String.format(
105+
"Cause expression type must be a subclass of Throwable, but found %s",
106+
causeExpr().type()));
107+
}
108+
66109
return autoBuild();
67110
}
68111
}

0 commit comments

Comments
 (0)