Skip to content

Commit dcde2c9

Browse files
authored
Hotfix 2.12.1 (#258)
* Fix NPE for ProjectIdentifier equals method
1 parent 85b310f commit dcde2c9

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

.qube.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ email: sven.fillinger@qbic.uni-tuebingen.de
44
project_name: data-model-lib
55
project_short_description: "Data models. A collection of QBiC's central data models\
66
\ and DTOs. "
7-
version: 2.12.0
7+
version: 2.12.1
88
domain: lib
99
language: groovy
1010
project_slug: data-model-lib

CHANGELOG.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ Changelog
44

55
This project adheres to `Semantic Versioning <https://semver.org/>`_.
66

7+
2.12.1 (2021-09-13)
8+
-------------------
9+
10+
**Added**
11+
12+
**Fixed**
13+
14+
* NPE when comparing ``life.qbic.datamodel.dtos.projectmanagement.ProjectIdentifier`` to null reference (`#258 <https://github.com/qbicsoftware/data-model-lib/pull/258>`_)
15+
16+
**Dependencies**
17+
18+
**Deprecated**
19+
720
2.12.0 (2021-09-10)
821
-------------------
922

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>life.qbic</groupId>
99
<artifactId>data-model-lib</artifactId>
10-
<version>2.12.0-SNAPSHOT</version> <!-- <<QUBE_FORCE_BUMP>> -->
10+
<version>2.12.1-SNAPSHOT</version> <!-- <<QUBE_FORCE_BUMP>> -->
1111
<name>data-model-lib</name>
1212
<url>http://github.com/qbicsoftware/data-model-lib</url>
1313
<description>Data models. A collection of QBiC's central data models and DTOs. </description>

src/main/groovy/life/qbic/datamodel/dtos/projectmanagement/ProjectIdentifier.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class ProjectIdentifier {
3636

3737
@Override
3838
boolean equals(Object obj) {
39+
if (obj == null) {
40+
return false
41+
}
3942
if (this.is(obj)) {
4043
return true
4144
}

src/test/groovy/life/qbic/datamodel/dtos/projectmanagement/ProjectIdentifierSpec.groovy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,26 @@ class ProjectIdentifierSpec extends Specification{
4040

4141
}
4242

43+
/**
44+
* Tests for Joshua Bloch's Item 8 in Effective Java, how to override equals() properly.
45+
* https://biratkirat.medium.com/learning-effective-java-item-8-d05f3847213d
46+
*/
47+
def "Test equals method fulfills full method contract"() {
48+
when:
49+
ProjectIdentifier idX = new ProjectIdentifier(new ProjectSpace(projectSpace), new ProjectCode(projectCode))
50+
ProjectIdentifier idY = new ProjectIdentifier(new ProjectSpace(projectSpace), new ProjectCode(projectCode))
51+
ProjectIdentifier idZ = new ProjectIdentifier(new ProjectSpace(projectSpace), new ProjectCode(projectCode))
52+
53+
then:
54+
idX.equals(idX) == true // Reflexive
55+
(idX.equals(idY) == true) && (idY.equals(idX) == true) // Symmetric
56+
(idX.equals(idY) == true) && (idY.equals(idZ) == true) && (idX.equals(idZ) == true) // Transitive
57+
(idX.equals(idX) == true) && (idX.equals(idX) == true) // Consistent
58+
idX.equals(null) == false // Non-nullity
59+
60+
where:
61+
projectSpace | projectCode
62+
"TEST" | "QTEST"
63+
}
64+
4365
}

0 commit comments

Comments
 (0)