Skip to content

Commit ba3fe35

Browse files
Merge pull request #167 from xdev-software/develop
v2.2.2
2 parents d104f61 + cdf3767 commit ba3fe35

File tree

7 files changed

+165
-3
lines changed

7 files changed

+165
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.2.2
2+
3+
* Fixed NPE in EclipseSerializerRegisteringCopier
4+
15
# 2.2.1
26

37
* Fixed release version

docs/antora.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: ROOT
22
title: Spring-Data-Eclipse-Store
33
version: master
4-
display_version: '2.2.1'
4+
display_version: '2.2.2'
55
start_page: index.adoc
66
nav:
77
- modules/ROOT/nav.adoc
88
asciidoc:
99
attributes:
1010
product-name: 'Spring-Data-Eclipse-Store'
11-
display-version: '2.2.1'
12-
maven-version: '2.2.1'
11+
display-version: '2.2.2'
12+
maven-version: '2.2.2'
1313
page-editable: false
1414
page-out-of-support: false

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/EclipseSerializerRegisteringCopier.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ private <T> T copy(final T source, final PersistenceManager<Binary> persistenceM
134134
loader.iterateEntries(
135135
(id, copiedObject) ->
136136
{
137+
if(copiedObject == null)
138+
{
139+
return;
140+
}
137141
if(copiedObject != null && !this.supportedChecker.isSupported(copiedObject.getClass()))
138142
{
139143
throw new DataTypeNotSupportedException(copiedObject.getClass());

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/IdTest.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdLong;
4141
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdLongRepository;
4242
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdString;
43+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdStringNoAutoGenerate;
44+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdStringNoAutoGenerateRepository;
4345
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdStringRepository;
4446
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdUuid;
4547
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdUuidRepository;
@@ -136,6 +138,45 @@ void saveBulkWithAutoIdIntAndHardcodedId(@Autowired final CustomerWithIdIntRepos
136138
);
137139
}
138140

141+
@Test
142+
void saveBulkWithNoAutoIdIntSameId(
143+
@Autowired final CustomerWithIdIntegerNoAutoGenerateRepository customerRepository)
144+
{
145+
final CustomerWithIdIntegerNoAutoGenerate customer1 =
146+
new CustomerWithIdIntegerNoAutoGenerate(1, TestData.FIRST_NAME, TestData.LAST_NAME);
147+
final CustomerWithIdIntegerNoAutoGenerate customer2 =
148+
new CustomerWithIdIntegerNoAutoGenerate(1, TestData.FIRST_NAME, TestData.LAST_NAME);
149+
Assertions.assertThrows(
150+
IllegalArgumentException.class,
151+
() -> customerRepository.saveAll(List.of(customer1, customer2))
152+
);
153+
}
154+
155+
@Test
156+
void saveBulkWithNoAutoIdStringSameId(
157+
@Autowired final CustomerWithIdStringNoAutoGenerateRepository customerRepository)
158+
{
159+
final CustomerWithIdStringNoAutoGenerate customer1 =
160+
new CustomerWithIdStringNoAutoGenerate("1", TestData.FIRST_NAME, TestData.LAST_NAME);
161+
final CustomerWithIdStringNoAutoGenerate customer2 =
162+
new CustomerWithIdStringNoAutoGenerate("1", TestData.FIRST_NAME, TestData.LAST_NAME);
163+
Assertions.assertThrows(
164+
IllegalArgumentException.class,
165+
() -> customerRepository.saveAll(List.of(customer1, customer2))
166+
);
167+
}
168+
169+
@Test
170+
void saveBulkWithNoAutoIdStringDifferentId(
171+
@Autowired final CustomerWithIdStringNoAutoGenerateRepository customerRepository)
172+
{
173+
final CustomerWithIdStringNoAutoGenerate customer1 =
174+
new CustomerWithIdStringNoAutoGenerate("1", TestData.FIRST_NAME, TestData.LAST_NAME);
175+
final CustomerWithIdStringNoAutoGenerate customer2 =
176+
new CustomerWithIdStringNoAutoGenerate("2", TestData.FIRST_NAME, TestData.LAST_NAME);
177+
Assertions.assertDoesNotThrow(() -> customerRepository.saveAll(List.of(customer1, customer2)));
178+
}
179+
139180
/**
140181
* In other tests {@link EclipseStoreStorage#clearData} is called. Here the datastore is restarted again to ensure
141182
* no previous method is called before the test.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
17+
18+
import java.util.Objects;
19+
20+
import jakarta.persistence.Id;
21+
22+
23+
public class CustomerWithIdStringNoAutoGenerate
24+
{
25+
@Id
26+
private String id;
27+
28+
private final String firstName;
29+
private final String lastName;
30+
31+
public CustomerWithIdStringNoAutoGenerate(final String id, final String firstName, final String lastName)
32+
{
33+
this.id = id;
34+
this.firstName = firstName;
35+
this.lastName = lastName;
36+
}
37+
38+
public String getFirstName()
39+
{
40+
return this.firstName;
41+
}
42+
43+
public String getLastName()
44+
{
45+
return this.lastName;
46+
}
47+
48+
@Override
49+
public String toString()
50+
{
51+
return String.format(
52+
"Customer[firstName='%s', lastName='%s']",
53+
this.firstName, this.lastName);
54+
}
55+
56+
@Override
57+
public boolean equals(final Object o)
58+
{
59+
if(this == o)
60+
{
61+
return true;
62+
}
63+
if(o == null || this.getClass() != o.getClass())
64+
{
65+
return false;
66+
}
67+
final CustomerWithIdStringNoAutoGenerate customer = (CustomerWithIdStringNoAutoGenerate)o;
68+
return Objects.equals(this.firstName, customer.firstName) && Objects.equals(
69+
this.lastName,
70+
customer.lastName);
71+
}
72+
73+
@Override
74+
public int hashCode()
75+
{
76+
return Objects.hash(this.firstName, this.lastName);
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
17+
18+
import org.springframework.data.repository.CrudRepository;
19+
20+
21+
public interface CustomerWithIdStringNoAutoGenerateRepository
22+
extends CrudRepository<CustomerWithIdStringNoAutoGenerate, String>
23+
{
24+
}

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/SimpleSingleTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package software.xdev.spring.data.eclipse.store.integration.shared.tests;
1717

18+
import java.util.ArrayList;
1819
import java.util.List;
1920
import java.util.Optional;
2021

@@ -130,6 +131,16 @@ void testNullSaveAll()
130131
Assertions.assertThrows(IllegalArgumentException.class, () -> this.repository.saveAll(null));
131132
}
132133

134+
@Test
135+
void testNullSaveAllWithList()
136+
{
137+
final Customer customer = new Customer(TestData.FIRST_NAME, TestData.LAST_NAME);
138+
final List<Customer> listWithNullElement = new ArrayList<>();
139+
listWithNullElement.add(customer);
140+
listWithNullElement.add(null);
141+
Assertions.assertDoesNotThrow(() -> this.repository.saveAll(listWithNullElement));
142+
}
143+
133144
@Test
134145
void testBasicSaveAndFindAll()
135146
{

0 commit comments

Comments
 (0)