Skip to content

Commit 307ddf3

Browse files
committed
Merge pull request #632 from mziccard/bigquery-hierachies
Fix NPE in bigquery XXXInfo.equals
2 parents 2bb9cb0 + 6955bf4 commit 307ddf3

File tree

8 files changed

+33
-26
lines changed

8 files changed

+33
-26
lines changed

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ public int hashCode() {
396396

397397
@Override
398398
public boolean equals(Object obj) {
399-
return obj.getClass().equals(DatasetInfo.class)
399+
return obj != null
400+
&& obj.getClass().equals(DatasetInfo.class)
400401
&& Objects.equals(toPb(), ((DatasetInfo) obj).toPb());
401402
}
402403

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import java.util.Objects;
2929

3030
/**
31-
* Google BigQuery external table type. BigQuery's external tables are tables whose data reside
32-
* outside of BigQuery but can be queried as normal BigQuery tables. External tables are
31+
* Google BigQuery external table definition. BigQuery's external tables are tables whose data
32+
* reside outside of BigQuery but can be queried as normal BigQuery tables. External tables are
3333
* experimental and might be subject to change or removed.
3434
*
3535
* @see <a href="https://cloud.google.com/bigquery/federated-data-sources">Federated Data Sources

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ public int hashCode() {
319319

320320
@Override
321321
public boolean equals(Object obj) {
322-
return obj.getClass().equals(JobInfo.class) && Objects.equals(toPb(), ((JobInfo) obj).toPb());
322+
return obj != null
323+
&& obj.getClass().equals(JobInfo.class)
324+
&& Objects.equals(toPb(), ((JobInfo) obj).toPb());
323325
}
324326

325327
JobInfo setProjectId(String projectId) {

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/StandardTableDefinition.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
import java.util.Objects;
2727

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

220221
/**
221-
* Returns a builder for a BigQuery default table type.
222+
* Returns a builder for a BigQuery standard table definition.
222223
*/
223224
public static Builder builder() {
224225
return new Builder();
225226
}
226227

227228
/**
228-
* Creates a BigQuery default table type given its schema.
229+
* Creates a BigQuery standard table definition given its schema.
229230
*
230231
* @param schema the schema of the table
231232
*/

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Table.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ public InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows,
213213
* @param options table data list options
214214
* @throws BigQueryException upon failure
215215
*/
216-
public Page<List<FieldValue>> list(BigQuery.TableDataListOption... options) throws BigQueryException {
216+
public Page<List<FieldValue>> list(BigQuery.TableDataListOption... options)
217+
throws BigQueryException {
217218
return bigquery.listTableData(tableId(), options);
218219
}
219220

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableDefinition.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.util.Objects;
2626

2727
/**
28-
* Base class for a Google BigQuery table type.
28+
* Base class for a Google BigQuery table definition.
2929
*/
3030
public abstract class TableDefinition implements Serializable {
3131

@@ -63,10 +63,10 @@ public enum Type {
6363
}
6464

6565
/**
66-
* Base builder for table types.
66+
* Base builder for table definitions.
6767
*
68-
* @param <T> the table type class
69-
* @param <B> the table type builder
68+
* @param <T> the table definition class
69+
* @param <B> the table definition builder
7070
*/
7171
public abstract static class Builder<T extends TableDefinition, B extends Builder<T, B>> {
7272

@@ -152,8 +152,8 @@ final int baseHashCode() {
152152
return Objects.hash(type);
153153
}
154154

155-
final boolean baseEquals(TableDefinition jobConfiguration) {
156-
return Objects.equals(toPb(), jobConfiguration.toPb());
155+
final boolean baseEquals(TableDefinition tableDefinition) {
156+
return Objects.equals(toPb(), tableDefinition.toPb());
157157
}
158158

159159
Table toPb() {

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ public int hashCode() {
339339

340340
@Override
341341
public boolean equals(Object obj) {
342-
return obj.getClass().equals(TableInfo.class)
342+
return obj != null
343+
&& obj.getClass().equals(TableInfo.class)
343344
&& Objects.equals(toPb(), ((TableInfo) obj).toPb());
344345
}
345346

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewDefinition.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
import java.util.Objects;
2828

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

170171
/**
171-
* Returns a builder for a BigQuery view type.
172+
* Returns a builder for a BigQuery view definition.
172173
*
173174
* @param query the query used to generate the view
174175
*/
@@ -177,7 +178,7 @@ public static Builder builder(String query) {
177178
}
178179

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

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

199200
/**
200-
* Creates a BigQuery view type given the query used to generate the table.
201+
* Creates a BigQuery view definition given the query used to generate the table.
201202
*
202203
* @param query the query used to generate the table
203204
*/
@@ -206,7 +207,7 @@ public static ViewDefinition of(String query) {
206207
}
207208

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

218219
/**
219-
* Creates a BigQuery view type given a query and some user-defined functions.
220+
* Creates a BigQuery view definition given a query and some user-defined functions.
220221
*
221222
* @param query the query used to generate the table
222223
* @param functions user-defined functions that can be used by the query

0 commit comments

Comments
 (0)