Skip to content

Commit 01d02d0

Browse files
committed
JSC: Null check for print()
git-svn-id: https://share-extras.googlecode.com/svn/trunk/Javascript Console@1365 a3f5c567-fd0f-3a89-9b71-a290c5a5f590
1 parent fc48218 commit 01d02d0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

javascript-console-repo/source/java/de/fme/jsconsole/JavascriptConsoleScriptObject.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public void print(Object obj) {
6767

6868
@SuppressWarnings("unchecked")
6969
private String formatValue(Object value) {
70+
71+
if (value == null) return "null";
72+
7073
if (value instanceof ScriptNode) {
7174
return formatScriptNode((ScriptNode) value);
7275
} else if (value instanceof ScriptContent) {
@@ -92,10 +95,12 @@ private String formatValue(Object value) {
9295
private String formatMap(Map<String, Object> map) {
9396
StringBuffer buffer = new StringBuffer();
9497
for (Map.Entry<String, Object> entry : map.entrySet()) {
95-
buffer.append(formatValue(entry.getKey()));
96-
buffer.append(" : ");
97-
buffer.append(formatValue(entry.getValue()));
98-
buffer.append("\n");
98+
if (entry != null) {
99+
buffer.append(formatValue(entry.getKey()));
100+
buffer.append(" : ");
101+
buffer.append(formatValue(entry.getValue()));
102+
buffer.append("\n");
103+
}
99104
}
100105
return buffer.toString();
101106
}

0 commit comments

Comments
 (0)