Fix tokens serialization bug

Change-Id: I0171fdb0a0d7c7444a61f0126a0739b67a4e42df
diff --git a/Changes b/Changes
index b2f2b5c..4da9845 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.58.4 2019-01-21
+0.58.4 2019-02-05
     - [cleanup] Remove deprecated methods setLicense/getLicense,
       setTokenization/getTokenization, setLayerInfo/getLayerInfo,
       setField/getField (including json serialization)
@@ -15,6 +15,8 @@
       (diewald)
     - [bugfix] Reintroduce getAvailability() method in AbstractDocument
       for compatibility with Kustvakt (diewald)
+    - [bugfix] Fix bug where tokens were serialized in getFields()
+      method (diewald)
 
 0.58.3 2018-12-17
     - [feature] Introduced attachements as meta data fields
diff --git a/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java b/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
index cd50c5d..413b1d0 100644
--- a/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
@@ -175,7 +175,7 @@
             String name = fieldsIter.next();
 
             // Remember - never serialize "tokens"
-            if (name == "tokens" || name == "UID")
+            if (name.equals("tokens") || name.equals("UID"))
                 continue;
 
             mFields.fieldsOrder.add(name);
@@ -188,7 +188,7 @@
             MetaField mf = mFields.add(iField);
 
             // Legacy
-            if (name == "license")
+            if (name.equals("license"))
                 this.addString("availability", doc.get("license"));
 
         };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
index ea49bb5..009ef7e 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -438,6 +438,9 @@
 				assertEquals("data:application/x.korap-link,https://de.wikipedia.org/wiki/Beispiel", field.at("/value").asText());
 				checkC++;
 				break;
+
+            default:
+                fail("Unknown field: " + key);
             };
         };
     };
@@ -539,6 +542,9 @@
 				assertEquals("2018-04-03", field.at("/value").asText());
 				checkC++;
 				break;
+
+            default:
+                fail("Unknown field: " + key);
             };
         };
     };