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 NPE in bigquery XXXInfo.equals #632

Merged
merged 3 commits into from
Feb 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -396,7 +396,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj.getClass().equals(DatasetInfo.class)
return obj != null
&& obj.getClass().equals(DatasetInfo.class)
&& Objects.equals(toPb(), ((DatasetInfo) obj).toPb());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import java.util.Objects;

/**
* Google BigQuery external table type. BigQuery's external tables are tables whose data reside
* outside of BigQuery but can be queried as normal BigQuery tables. External tables are
* Google BigQuery external table definition. BigQuery's external tables are tables whose data
* reside outside of BigQuery but can be queried as normal BigQuery tables. External tables are
* experimental and might be subject to change or removed.
*
* @see <a href="https://cloud.google.com/bigquery/federated-data-sources">Federated Data Sources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj.getClass().equals(JobInfo.class) && Objects.equals(toPb(), ((JobInfo) obj).toPb());
return obj != null
&& obj.getClass().equals(JobInfo.class)
&& Objects.equals(toPb(), ((JobInfo) obj).toPb());
}

JobInfo setProjectId(String projectId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
import java.util.Objects;

/**
* A Google BigQuery default table type. This type is used for standard, two-dimensional tables with
* individual records organized in rows, and a data type assigned to each column (also called a
* field). Individual fields within a record may contain nested and repeated children fields. Every
* table is described by a schema that describes field names, types, and other information.
* A Google BigQuery default table definition. This definition is used for standard, two-dimensional
* tables with individual records organized in rows, and a data type assigned to each column (also
* called a field). Individual fields within a record may contain nested and repeated children
* fields. Every table is described by a schema that describes field names, types, and other
* information.
*
* @see <a href="https://cloud.google.com/bigquery/docs/tables">Managing Tables</a>
*/
Expand Down Expand Up @@ -218,14 +219,14 @@ public StreamingBuffer streamingBuffer() {
}

/**
* Returns a builder for a BigQuery default table type.
* Returns a builder for a BigQuery standard table definition.
*/
public static Builder builder() {
return new Builder();
}

/**
* Creates a BigQuery default table type given its schema.
* Creates a BigQuery standard table definition given its schema.
*
* @param schema the schema of the table
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ public InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows,
* @param options table data list options
* @throws BigQueryException upon failure
*/
public Page<List<FieldValue>> list(BigQuery.TableDataListOption... options) throws BigQueryException {
public Page<List<FieldValue>> list(BigQuery.TableDataListOption... options)
throws BigQueryException {
return bigquery.listTableData(tableId(), options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.Objects;

/**
* Base class for a Google BigQuery table type.
* Base class for a Google BigQuery table definition.
*/
public abstract class TableDefinition implements Serializable {

Expand Down Expand Up @@ -63,10 +63,10 @@ public enum Type {
}

/**
* Base builder for table types.
* Base builder for table definitions.
*
* @param <T> the table type class
* @param <B> the table type builder
* @param <T> the table definition class
* @param <B> the table definition builder
*/
public abstract static class Builder<T extends TableDefinition, B extends Builder<T, B>> {

Expand Down Expand Up @@ -152,8 +152,8 @@ final int baseHashCode() {
return Objects.hash(type);
}

final boolean baseEquals(TableDefinition jobConfiguration) {
return Objects.equals(toPb(), jobConfiguration.toPb());
final boolean baseEquals(TableDefinition tableDefinition) {
return Objects.equals(toPb(), tableDefinition.toPb());
}

Table toPb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj.getClass().equals(TableInfo.class)
return obj != null
&& obj.getClass().equals(TableInfo.class)
&& Objects.equals(toPb(), ((TableInfo) obj).toPb());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import java.util.Objects;

/**
* Google BigQuery view table type. BigQuery's views are logical views, not materialized views,
* which means that the query that defines the view is re-executed every time the view is queried.
* Google BigQuery view table definition. BigQuery's views are logical views, not materialized
* views, which means that the query that defines the view is re-executed every time the view is
* queried.
*
* @see <a href="https://cloud.google.com/bigquery/querying-data#views">Views</a>
*/
Expand Down Expand Up @@ -168,7 +169,7 @@ Table toPb() {
}

/**
* Returns a builder for a BigQuery view type.
* Returns a builder for a BigQuery view definition.
*
* @param query the query used to generate the view
*/
Expand All @@ -177,7 +178,7 @@ public static Builder builder(String query) {
}

/**
* Returns a builder for a BigQuery view type.
* Returns a builder for a BigQuery view definition.
*
* @param query the query used to generate the table
* @param functions user-defined functions that can be used by the query
Expand All @@ -187,7 +188,7 @@ public static Builder builder(String query, List<UserDefinedFunction> functions)
}

/**
* Returns a builder for a BigQuery view type.
* Returns a builder for a BigQuery view definition.
*
* @param query the query used to generate the table
* @param functions user-defined functions that can be used by the query
Expand All @@ -197,7 +198,7 @@ public static Builder builder(String query, UserDefinedFunction... functions) {
}

/**
* Creates a BigQuery view type given the query used to generate the table.
* Creates a BigQuery view definition given the query used to generate the table.
*
* @param query the query used to generate the table
*/
Expand All @@ -206,7 +207,7 @@ public static ViewDefinition of(String query) {
}

/**
* Creates a BigQuery view type given a query and some user-defined functions.
* Creates a BigQuery view definition given a query and some user-defined functions.
*
* @param query the query used to generate the table
* @param functions user-defined functions that can be used by the query
Expand All @@ -216,7 +217,7 @@ public static ViewDefinition of(String query, List<UserDefinedFunction> function
}

/**
* Creates a BigQuery view type given a query and some user-defined functions.
* Creates a BigQuery view definition given a query and some user-defined functions.
*
* @param query the query used to generate the table
* @param functions user-defined functions that can be used by the query
Expand Down