OSDN Git Service

Handle null values in registerService
authorChristopher Lane <lanechr@google.com>
Sat, 13 Sep 2014 18:13:39 +0000 (11:13 -0700)
committerChristopher Lane <lanechr@google.com>
Sat, 13 Sep 2014 18:18:33 +0000 (11:18 -0700)
Bug: 17491971
Change-Id: I0443a9accd86ab70510d16456a03912845718ca9

services/core/java/com/android/server/NsdService.java

index cb1748d..39aa972 100644 (file)
@@ -716,8 +716,9 @@ public class NsdService extends INsdManager.Stub {
             for (String key : txtRecords.keySet()) {
                 try {
                     // TODO: Send encoded TXT record as bytes once NDC/netd supports binary data.
+                    byte[] recordValue = txtRecords.get(key);
                     cmd.appendArg(String.format(Locale.US, "%s=%s", key,
-                            new String(txtRecords.get(key), "UTF_8")));
+                            recordValue != null ? new String(recordValue, "UTF_8") : ""));
                 } catch (UnsupportedEncodingException e) {
                     Slog.e(TAG, "Failed to encode txtRecord " + e);
                 }