Skip to content

Commit

Permalink
fix: potential NPE for WriteParameters#hashCode (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Dec 13, 2022
1 parent 9b07e6e commit 00f4f81
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Bug Fixes
1. [#470](https://github.com/influxdata/influxdb-client-java/pull/470): Move auto-configuration registration to `AutoConfiguration.imports` [spring]
1. [#483](https://github.com/influxdata/influxdb-client-java/pull/483): Fix of potential NPE for `WriteParameters#hashCode`

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ public boolean equals(final Object o) {
@Override
@SuppressWarnings("MagicNumber")
public int hashCode() {
int result = bucket.hashCode();
result = 31 * result + org.hashCode();
result = 31 * result + precision.hashCode();
int result = bucket != null ? bucket.hashCode() : 0;
result = 31 * result + (org != null ? org.hashCode() : 0);
result = 31 * result + (precision != null ? precision.hashCode() : 0);
result = 31 * result + (consistency != null ? consistency.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,12 @@ void v1Constructor() {
Assertions.assertThat(parameters.precisionSafe(options)).isEqualTo(WritePrecision.NS);
Assertions.assertThat(parameters.consistencySafe(options)).isEqualTo(WriteConsistency.ONE);
}

@Test
void npe() {
WriteParameters parameters = new WriteParameters(null, null, null, null);

Assertions.assertThat(parameters.hashCode()).isNotNull();
Assertions.assertThat(parameters).isEqualTo(parameters);
}
}

0 comments on commit 00f4f81

Please sign in to comment.