Skip to content

Commit fe00e92

Browse files
committed
DATAJDBC-162 - Prevent NPE for missing PropertyPath in DbActionExecutionException.
1 parent 235abe4 commit fe00e92

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/main/java/org/springframework/data/jdbc/core/conversion/DbActionExecutionException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 the original author or authors.
2+
* Copyright 2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ public DbActionExecutionException(DbAction<?> action, Throwable cause) {
2828
action.getClass().getSimpleName(), //
2929
action.getEntity(), //
3030
action.getEntityType(), //
31-
action.getPropertyPath().toDotPath() //
31+
action.getPropertyPath() == null ? "" : action.getPropertyPath().toDotPath() //
3232
), //
3333
cause);
3434
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2018 the original author or authors.
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 org.springframework.data.jdbc.core.conversion;
17+
18+
import static org.mockito.Mockito.*;
19+
20+
import org.junit.Test;
21+
22+
/**
23+
* @author Jens Schauder
24+
*/
25+
public class DbActionExecutionExceptionTest {
26+
27+
@Test // DATAJDBC-162
28+
public void constructorWorksWithNullPropertyPath() {
29+
30+
DbAction<?> action = mock(DbAction.class);
31+
new DbActionExecutionException(action, null);
32+
}
33+
34+
}

0 commit comments

Comments
 (0)