Skip to content

Commit

Permalink
NMS-15768: Added null check
Browse files Browse the repository at this point in the history
  • Loading branch information
christianpape committed Jun 27, 2023
1 parent e5d6320 commit 9357535
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public String marshal(final Duration v) {
/** {@inheritDoc} */
@Override
public Duration unmarshal(final String v) {
if (v == null) {
return null;
}
if ("0".equals(v.trim())) {
return Duration.ZERO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ public class StringIntervalPropertyEditor extends PropertyEditorSupport implemen
/** {@inheritDoc} */
@Override
public void setAsText(final String text) throws IllegalArgumentException {
if ("0".equals(text.trim())) {
setValue(Duration.ZERO);
if (text == null) {
setValue(null);
} else {
if ("-1".equals(text.trim())) {
setValue(Duration.ZERO.minus(1000));
if ("0".equals(text.trim())) {
setValue(Duration.ZERO);
} else {
setValue(StringIntervalAdapter.DEFAULT_PERIOD_FORMATTER.parsePeriod(text.trim()).toStandardDuration());
if ("-1".equals(text.trim())) {
setValue(Duration.ZERO.minus(1000));
} else {
setValue(StringIntervalAdapter.DEFAULT_PERIOD_FORMATTER.parsePeriod(text.trim()).toStandardDuration());
}
}
}
}
Expand Down

0 comments on commit 9357535

Please sign in to comment.