diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-12 11:41:41 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-12 11:41:41 +0000 |
commit | 02fa1bc6828cf80cc34040769d92db4ae9361cc9 (patch) | |
tree | 3fc17ad0ca5923f0eca1121a7ddee23670c68906 /document/src | |
parent | 55b8a24439e9dc41122a98bd7537968983e8a9ec (diff) |
Fix comments and messages and unify on '>'.
Diffstat (limited to 'document/src')
3 files changed, 16 insertions, 14 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentId.java b/document/src/main/java/com/yahoo/document/DocumentId.java index 30ca9be8231..26adb0b6dc5 100644 --- a/document/src/main/java/com/yahoo/document/DocumentId.java +++ b/document/src/main/java/com/yahoo/document/DocumentId.java @@ -2,7 +2,10 @@ package com.yahoo.document; import com.yahoo.document.idstring.IdString; -import com.yahoo.document.serialization.*; +import com.yahoo.document.serialization.DeserializationException; +import com.yahoo.document.serialization.DocumentReader; +import com.yahoo.document.serialization.DocumentWriter; +import com.yahoo.document.serialization.SerializationException; import com.yahoo.vespa.objects.Deserializer; import com.yahoo.vespa.objects.Identifiable; import com.yahoo.vespa.objects.Serializer; @@ -34,7 +37,7 @@ public class DocumentId extends Identifiable implements Serializable { throw new IllegalArgumentException("Cannot create DocumentId from null id."); } if (id.length() > IdString.MAX_LENGTH) { - throw new IllegalArgumentException("The document id(" + id.length() + ") is too long(65536). " + + throw new IllegalArgumentException("The document id(" + id.length() + ") is too long(" + IdString.MAX_LENGTH + "). " + "However if you have already fed a document earlier on and want to remove it, you can do so by " + "calling new DocumentId(IdString.createIdStringLessStrict()) that will bypass this restriction."); } diff --git a/document/src/main/java/com/yahoo/document/idstring/IdString.java b/document/src/main/java/com/yahoo/document/idstring/IdString.java index 404db928f30..c5f5a088bf9 100644 --- a/document/src/main/java/com/yahoo/document/idstring/IdString.java +++ b/document/src/main/java/com/yahoo/document/idstring/IdString.java @@ -53,7 +53,7 @@ public abstract class IdString { * The document id string can only contain text characters. */ public static IdString createIdString(String id) { - if (id.length() >= MAX_LENGTH) { + if (id.length() > MAX_LENGTH) { throw new IllegalArgumentException("Document id length " + id.length() + " is longer than max length of " + MAX_LENGTH); } validateTextString(id); diff --git a/document/src/test/java/com/yahoo/document/IdIdStringTest.java b/document/src/test/java/com/yahoo/document/IdIdStringTest.java index a94c3445d27..493fb35c97d 100644 --- a/document/src/test/java/com/yahoo/document/IdIdStringTest.java +++ b/document/src/test/java/com/yahoo/document/IdIdStringTest.java @@ -6,7 +6,6 @@ import com.yahoo.document.idstring.IdString; import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** @@ -17,19 +16,19 @@ import static org.junit.Assert.fail; */ public class IdIdStringTest { @Test - public void requireThatIdIdStringGeneratesProperString() throws Exception { + public void requireThatIdIdStringGeneratesProperString() { DocumentId docId = new DocumentId(new IdIdString("namespace", "type", "g=group", "foobar")); assertEquals("id:namespace:type:g=group:foobar", docId.toString()); } @Test - public void requireThatEmptyKeyValuesAreOk() throws Exception { + public void requireThatEmptyKeyValuesAreOk() { DocumentId docId = new DocumentId(new IdIdString("namespace", "type", "", "foobar")); assertEquals("id:namespace:type::foobar", docId.toString()); } @Test - public void requireThatIdIdStringCanBehaveLikeGroupDoc() throws Exception { + public void requireThatIdIdStringCanBehaveLikeGroupDoc() { DocumentId docId1 = new DocumentId(new IdIdString("namespace", "type", "g=foo", "foo")); DocumentId docId2 = new DocumentId(new IdIdString("namespace", "type", "g=foo", "bar")); DocumentId docId3 = new DocumentId(new IdIdString("namespace", "type", "g=bar", "baz")); @@ -38,7 +37,7 @@ public class IdIdStringTest { } @Test - public void requireThatIdIdStringCanBehaveLikeUserDoc() throws Exception { + public void requireThatIdIdStringCanBehaveLikeUserDoc() { DocumentId docId1 = new DocumentId(new IdIdString("namespace", "type", "n=10", "foo")); DocumentId docId2 = new DocumentId(new IdIdString("namespace", "type", "n=10", "bar")); DocumentId docId3 = new DocumentId(new IdIdString("namespace", "type", "n=20", "baz")); @@ -47,7 +46,7 @@ public class IdIdStringTest { } @Test - public void requireThatIllegalKeyValuesThrow() throws Exception { + public void requireThatIllegalKeyValuesThrow() { try { new IdIdString("namespace", "type", "illegal=key", "foo"); fail(); @@ -57,7 +56,7 @@ public class IdIdStringTest { } @Test - public void requireThatKeysWithoutValuesThrow() throws Exception { + public void requireThatKeysWithoutValuesThrow() { try { new IdIdString("namespace", "type", "illegal-pair", "foo"); fail(); @@ -67,7 +66,7 @@ public class IdIdStringTest { } @Test - public void requireTooLongIdThrowsWhileParsing() throws Exception { + public void requireTooLongIdThrowsWhileParsing() { StringBuilder builder = new StringBuilder("id:ns:type::namespacespecificpart_01"); for (int i = 0; i < 0x10000; i++) { builder.append('n'); @@ -78,12 +77,12 @@ public class IdIdStringTest { } catch (IllegalArgumentException e) { assertEquals("Document id length 65572 is longer than max length of 65536", e.getMessage()); } - // But there is a backdor + // But there is a backdoor assertEquals(65572, IdString.createIdStringLessStrict(builder.toString()).toString().length()); } @Test - public void requireThatTooLongPreNamespaceSpecificThrowsWhileParsing() throws Exception { + public void requireThatTooLongPreNamespaceSpecificThrowsWhileParsing() { StringBuilder builder = new StringBuilder("id:"); for (int i = 0; i < 0xff00; i++) { builder.append('n'); @@ -111,7 +110,7 @@ public class IdIdStringTest { } @Test - public void requireThatIdIdStringCanReplaceType() throws Exception { + public void requireThatIdIdStringCanReplaceType() { String type = IdIdString.replaceType("id:namespace:type::foo", "newType"); assertEquals("id:namespace:newType::foo", type); } |