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

Bug fixes to compile when imported internally. #4499

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@ public String extractNextToken(ListDatabasesResponse payload) {

@Override
public Iterable<Database> extractResources(ListDatabasesResponse payload) {
return payload.getDatabasesList() != null
? payload.getDatabasesList()
: ImmutableList.<Database>of();
return payload.getDatabasesList();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this change behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, protobufs are not null and this check is not necessary.
I will need to file a bug for gapic-generators to fix this semantics.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh. If this is generated code, I'm afraid that we won't be able to check this in. We'd need a generator change instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sduskis This doesnt change behavior.

@snehashah16 This was done to protected against NPE in paged iteration. Some client like compute do return null instead of empty list. This was done to fix one of such bug #3736

}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,7 @@ public String extractNextToken(ListInstanceConfigsResponse payload) {

@Override
public Iterable<InstanceConfig> extractResources(ListInstanceConfigsResponse payload) {
return payload.getInstanceConfigsList() != null
? payload.getInstanceConfigsList()
: ImmutableList.<InstanceConfig>of();
return payload.getInstanceConfigsList();
}
};

Expand Down Expand Up @@ -350,9 +348,7 @@ public String extractNextToken(ListInstancesResponse payload) {

@Override
public Iterable<Instance> extractResources(ListInstancesResponse payload) {
return payload.getInstancesList() != null
? payload.getInstancesList()
: ImmutableList.<Instance>of();
return payload.getInstancesList();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ public String extractNextToken(ListSessionsResponse payload) {

@Override
public Iterable<Session> extractResources(ListSessionsResponse payload) {
return payload.getSessionsList() != null
? payload.getSessionsList()
: ImmutableList.<Session>of();
return payload.getSessionsList() != null;
nithinsujir marked this conversation as resolved.
Show resolved Hide resolved
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ public void getDoubleArray() {
consumer.onCompleted();

assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getDoubleArray(0)).isEqualTo(doubleArray, 0.0);
assertThat(resultSet.getDoubleArray(0)).isEqualTo(doubleArray);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public void allOptionsAbsent() {
assertThat(options.toString()).isEqualTo("");
assertThat(options.equals(options)).isTrue();
assertThat(options.equals(null)).isFalse();
assertThat(options.equals(this)).isFalse();
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like an interesting test. Why was it removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is testing 2 different objects( OptionsTest against Options). This may not be interesting because it should always result in false.

Copy link
Contributor

Choose a reason for hiding this comment

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

Testing equals against different objects seems like it would exercise a unique codepath, which is "interesting". Shouldn't we keep this test?


assertThat(options.hashCode()).isEqualTo(31);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public void resultSetIteration() {
assertThat(rs.getLongArray("longArray")).isEqualTo(longArray);
assertThat(rs.getLongList(9)).isEqualTo(Longs.asList(longArray));
assertThat(rs.getLongList("longArray")).isEqualTo(Longs.asList(longArray));
assertThat(rs.getDoubleArray(10)).isEqualTo(doubleArray, 0.0);
assertThat(rs.getDoubleArray("doubleArray")).isEqualTo(doubleArray, 0.0);
assertThat(rs.getDoubleArray(10)).isEqualTo(doubleArray);
assertThat(rs.getDoubleArray("doubleArray")).isEqualTo(doubleArray);
assertThat(rs.getDoubleList(10)).isEqualTo(Doubles.asList(doubleArray));
assertThat(rs.getDoubleList("doubleArray")).isEqualTo(Doubles.asList(doubleArray));
assertThat(rs.getBytesList(11)).isEqualTo(Arrays.asList(byteArray));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public Void call() throws Exception {
});
} catch (SpannerException e) {
assertThat(e.getErrorCode()).isEqualTo(ErrorCode.INTERNAL);
assertThat(e.getMessage().contains("Unexpected exception thrown"));
assertThat(e.getMessage()).contains("Unexpected exception thrown");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class SpannerMetadataProviderTest {
@Test
public void testGetHeadersAsMetadata() {
Expand Down