4242import io .usethesource .vallang .ITuple ;
4343import io .usethesource .vallang .IValue ;
4444import io .usethesource .vallang .visitors .IValueVisitor ;
45+ import jline .internal .Nullable ;
4546
4647/**
4748 * This class streams am IValue stream directly to an JSon stream. Useful to communicate IValues to browsers.
@@ -96,14 +97,17 @@ public JsonValueWriter() {
9697 /**
9798 * Builder method to set the format to use for all date-time values encoded as strings
9899 */
99- public JsonValueWriter setCalendarFormat (String format ) {
100- // SimpleDateFormat is not thread safe, so here we make sure
101- // we can use objects of this reader in different threads at the same time
102- this .format = new ThreadLocal <SimpleDateFormat >() {
103- protected SimpleDateFormat initialValue () {
104- return new SimpleDateFormat (format );
105- }
106- };
100+ public JsonValueWriter setCalendarFormat (@ Nullable String format ) {
101+ if (format != null ) {
102+ // SimpleDateFormat is not thread safe, so here we make sure
103+ // we can use objects of this reader in different threads at the same time
104+ this .format = new ThreadLocal <SimpleDateFormat >() {
105+ protected SimpleDateFormat initialValue () {
106+ return new SimpleDateFormat (format );
107+ }
108+ };
109+ }
110+
107111 return this ;
108112 }
109113
@@ -122,8 +126,8 @@ public JsonValueWriter setDropOrigins(boolean setting) {
122126 return this ;
123127 }
124128
125- public JsonValueWriter setFormatters (IFunction formatters ) {
126- if (formatters .getType ().getFieldType (0 ).isTop ()) {
129+ public JsonValueWriter setFormatters (@ Nullable IFunction formatters ) {
130+ if (formatters != null && formatters .getType ().getFieldType (0 ).isTop ()) {
127131 // ignore default function
128132 formatters = null ;
129133 }
0 commit comments