Skip to content

On result2 resolution result have addresses or error #11330

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a4e92d6
Introducing NameResolver Listener2::onResult2 that returns Status of …
kannanjgithub Jun 24, 2024
8ac1581
Add comment for the deprecation.
kannanjgithub Jun 24, 2024
82dc9c5
Introducing NameResolver Listener2::onResult2 that returns Status of …
kannanjgithub Jun 24, 2024
a42e66e
Merge remote-tracking branch 'origin/onResult2' into onResult2
kannanjgithub Jun 24, 2024
5e8b3ea
Whitespace fix.
kannanjgithub Jun 24, 2024
7deb491
Combining passing name resolution result or error via ResolutionResult.
kannanjgithub Jun 26, 2024
fb39b62
Combining passing name resolution result or error via ResolutionResult.
kannanjgithub Jun 26, 2024
3a1f3eb
Merge remote-tracking branch 'origin/onResult2_resolutionResultHaveAd…
kannanjgithub Jun 26, 2024
7169585
nit.
kannanjgithub Jun 26, 2024
3aedd65
Test fixes.
kannanjgithub Jun 26, 2024
96a7612
Merge branch 'grpc:master' into onResult2_resolutionResultHaveAddress…
kannanjgithub Jul 20, 2024
8909812
Merge branch 'master' into onResult2_resolutionResultHaveAddressesOrE…
kannanjgithub Jul 26, 2024
96890d2
nit
kannanjgithub Jul 26, 2024
57ee8e2
Fix merge errors.
kannanjgithub Jul 27, 2024
b1e7802
Fix warnings.
kannanjgithub Jul 27, 2024
f2a7b32
Fix style issues.
kannanjgithub Jul 27, 2024
4c0742d
Fix style issues.
kannanjgithub Jul 27, 2024
7f83dee
Fix a failing test, and address review comments for StatusOr.java
kannanjgithub Jul 29, 2024
f725239
Fix style issues.
kannanjgithub Jul 29, 2024
5dc6cd9
Fix tests.
kannanjgithub Jul 29, 2024
3102374
Fix style.
kannanjgithub Jul 29, 2024
d6ee012
Fix tests
kannanjgithub Jul 30, 2024
c44fbc2
Remove the warning as error added in my previous commit since in koko…
kannanjgithub Jul 30, 2024
27af56b
Trigger Build to retry the Android test RetriableStreamTest that fail…
kannanjgithub Jul 30, 2024
d02e4aa
Implement equals and hashCode in StatusOr and other things discussed.
kannanjgithub Aug 12, 2024
49dffd5
Fix warning as error for unchecked cast
kannanjgithub Aug 12, 2024
fea7744
Add suppress unchecked cast
kannanjgithub Aug 12, 2024
ad34729
Fix copyright year.
kannanjgithub Aug 12, 2024
e7f7fda
Revert back of() in favor of fromValue(). Made getValue() throw Illeg…
kannanjgithub Sep 26, 2024
97cb232
Merge remote-tracking branch 'origin/onResult2_resolutionResultHaveAd…
kannanjgithub Sep 26, 2024
e136fe5
Add experimental API label. Allow null value.
kannanjgithub Sep 26, 2024
bcf8578
Merge branch 'grpc:master' into onResult2_resolutionResultHaveAddress…
kannanjgithub Oct 4, 2024
18681d1
Address review comments.
kannanjgithub Oct 4, 2024
b67a02b
Merge remote-tracking branch 'origin/onResult2_resolutionResultHaveAd…
kannanjgithub Oct 4, 2024
70056e4
Fix review comments.
kannanjgithub Oct 4, 2024
7dff20e
Address review comments.
kannanjgithub Oct 4, 2024
c80aafb
Fix code coverage by adding missing test cases.
kannanjgithub Oct 4, 2024
1706016
Fix new review comments.
kannanjgithub Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix review comments.
  • Loading branch information
kannanjgithub committed Oct 4, 2024
commit 70056e48aa5ef926ff84a3eaf9bf456d1a77865f
4 changes: 2 additions & 2 deletions api/src/main/java/io/grpc/NameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@

@Override
public void onResult(ResolutionResult resolutionResult) {
listener.onAddresses(resolutionResult.getAddressesOrError().getValue(),
resolutionResult.getAttributes());

Check warning on line 98 in api/src/main/java/io/grpc/NameResolver.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/NameResolver.java#L97-L98

Added lines #L97 - L98 were not covered by tests
}
});
}
Expand Down Expand Up @@ -224,9 +224,9 @@
public final void onAddresses(
List<EquivalentAddressGroup> servers, @ResolutionResultAttr Attributes attributes) {
// TODO(jihuncho) need to promote Listener2 if we want to use ConfigOrError
onResult2(
ResolutionResult.newBuilder().setAddressesOrError(
StatusOr.fromValue(servers)).setAttributes(attributes).build());

Check warning on line 229 in api/src/main/java/io/grpc/NameResolver.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/NameResolver.java#L227-L229

Added lines #L227 - L229 were not covered by tests
}

/**
Expand Down Expand Up @@ -606,7 +606,7 @@
List<EquivalentAddressGroup> addresses,
@ResolutionResultAttr Attributes attributes,
ConfigOrError serviceConfig) {
this.addressesOrError = StatusOr.fromValue(addresses);

Check warning on line 609 in api/src/main/java/io/grpc/NameResolver.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/NameResolver.java#L609

Added line #L609 was not covered by tests
this.attributes = checkNotNull(attributes, "attributes");
this.serviceConfig = serviceConfig;
}
Expand Down Expand Up @@ -676,7 +676,7 @@
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("addresses", addressesOrError)

Check warning on line 679 in api/src/main/java/io/grpc/NameResolver.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/NameResolver.java#L679

Added line #L679 was not covered by tests
.add("attributes", attributes)
.add("serviceConfig", serviceConfig)
.toString();
Expand All @@ -701,7 +701,7 @@
*/
@Override
public int hashCode() {
return Objects.hashCode(addressesOrError, attributes, serviceConfig);

Check warning on line 704 in api/src/main/java/io/grpc/NameResolver.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/NameResolver.java#L704

Added line #L704 was not covered by tests
}

/**
Expand All @@ -728,7 +728,7 @@
*/
@Deprecated
public Builder setAddresses(List<EquivalentAddressGroup> addresses) {
this.addresses = StatusOr.fromValue(addresses);
setAddressesOrError(StatusOr.fromValue(addresses));
return this;
}

Expand All @@ -738,7 +738,7 @@
* @param addresses Resolved addresses or an error in resolving addresses
*/
public Builder setAddressesOrError(StatusOr<List<EquivalentAddressGroup>> addresses) {
this.addresses = addresses;
this.addresses = checkNotNull(addresses, "StatusOr addresses cannot be null.");
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/io/grpc/StatusOr.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,29 @@
*/
public @Nullable T getValue() {
if (status != null) {
throw new IllegalStateException("No value present.");

Check warning on line 57 in api/src/main/java/io/grpc/StatusOr.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/StatusOr.java#L57

Added line #L57 was not covered by tests
}
return value;
}

/** Returns the status. If there is a value (which can be null), returns OK. */
public Status getStatus() {
return status == null? Status.OK : status;
return status == null ? Status.OK : status;
}

@Override
public boolean equals(Object other) {
if (!(other instanceof StatusOr)) {
return false;

Check warning on line 70 in api/src/main/java/io/grpc/StatusOr.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/StatusOr.java#L70

Added line #L70 was not covered by tests
}
StatusOr<?> otherStatus = (StatusOr<?>) other;

Check warning on line 72 in api/src/main/java/io/grpc/StatusOr.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/StatusOr.java#L72

Added line #L72 was not covered by tests
if (hasValue() != otherStatus.hasValue()) {
return false;

Check warning on line 74 in api/src/main/java/io/grpc/StatusOr.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/StatusOr.java#L74

Added line #L74 was not covered by tests
}
if (hasValue()) {
return Objects.equal(value, otherStatus.value);

Check warning on line 77 in api/src/main/java/io/grpc/StatusOr.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/StatusOr.java#L77

Added line #L77 was not covered by tests
}
return Objects.equal(status, otherStatus.status);

Check warning on line 79 in api/src/main/java/io/grpc/StatusOr.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/io/grpc/StatusOr.java#L79

Added line #L79 was not covered by tests
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@

StatusOr<List<EquivalentAddressGroup>> serversOrError =
resolutionResult.getAddressesOrError();
if (serversOrError != null && serversOrError.hasValue()) {
if (serversOrError.hasValue()) {
channelLogger.log(
ChannelLogLevel.DEBUG,
"Resolved address: {0}, config={1}",
Expand Down Expand Up @@ -1825,7 +1825,7 @@
if (serversOrError != null && serversOrError.hasValue()) {
resolvedAddresses.setAddresses(serversOrError.getValue());
} else {
resolvedAddresses.setAddresses(new ArrayList<>());

Check warning on line 1828 in core/src/main/java/io/grpc/internal/ManagedChannelImpl.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/io/grpc/internal/ManagedChannelImpl.java#L1828

Added line #L1828 was not covered by tests
}
resolvedAddresses = resolvedAddresses.setAttributes(attributes)
.setLoadBalancingPolicyConfig(effectiveServiceConfig.getLoadBalancingConfig());
Expand Down
Loading