Skip to content

Commit f886b23

Browse files
author
Alexey Belostotskiy
committed
#52 fix NPE
1 parent f33f8e3 commit f886b23

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>ru.mail.jira.plugins</groupId>
66
<artifactId>groovy</artifactId>
7-
<version>1.20.0-jira8</version>
7+
<version>1.20.1-jira8</version>
88
<organization>
99
<name>AtlasTeam</name>
1010
<url>https://atlasteam.ru/</url>

src/main/java/ru/mail/jira/plugins/groovy/impl/cf/FieldValueExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private <T> T doExtractValue(
201201
result = ((Number) result).doubleValue();
202202
}
203203

204-
if (!tType.isInstance(result)) {
204+
if (result != null && !tType.isInstance(result)) {
205205
logger.error("Result type ({}) doesn't match field type {}", result.getClass(), tType);
206206
}
207207
//todo: try to check collections in future if multi

src/test/java/it/ru/mail/jira/plugins/groovy/ScriptFieldIT.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
import java.util.Set;
2626
import java.util.concurrent.TimeUnit;
2727

28-
import static org.junit.Assert.assertEquals;
29-
import static org.junit.Assert.assertNotNull;
28+
import static org.junit.Assert.*;
3029

3130
@RunWith(Arquillian.class)
3231
public class ScriptFieldIT {
@@ -107,6 +106,29 @@ public void scriptedFieldShouldWork() throws Exception {
107106
);
108107
}
109108

109+
@Test
110+
public void nullValuesFieldShouldWork() throws Exception {
111+
this.field = fieldHelper.createNumberField();
112+
this.issue = issueHelper.createIssue(userHelper.getAdmin(), project);
113+
114+
FieldConfig fieldConfig = fieldHelper.getFirstConfig(field);
115+
116+
assertNotNull(fieldConfig);
117+
118+
String script = "return null";
119+
120+
FieldConfigForm form = new FieldConfigForm();
121+
form.setCacheable(true);
122+
form.setScriptBody(script);
123+
form.setVelocityParamsEnabled(false);
124+
125+
fieldConfigRepository.updateConfig(userHelper.getAdmin(), fieldConfig.getId(), form);
126+
127+
MutableIssue issue = issueManager.getIssueObject(this.issue.getId());
128+
129+
assertNull(issue.getCustomFieldValue(field));
130+
}
131+
110132
private boolean isIssueReIndexed(ApplicationUser expectedAssignee) throws Exception {
111133
return issueHelper.search(
112134
userHelper.getAdmin(),

0 commit comments

Comments
 (0)