[ 
https://issues.apache.org/jira/browse/OAK-12114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18062491#comment-18062491
 ] 

Julian Reschke commented on OAK-12114:
--------------------------------------

As [~daim] said, the difference in behavior was caused by the fact that "all 
ASCII" (where ASCII is really <= 127) actually maps the same octets in UTF-8 
(same length), while random characters (including non ASCII) will need more 
bytes in UTF-8.

So a) I'm documenting this in the test, and b) add sanity checks so that we 
will detect it if BSON behavior somehow changes.

Note that BSON does not compress, it just serializes to binary. What happens on 
the wire or in the DB in invisible for uns, unless something fails.



> MongoDBExceptionTest add checks for bson compression
> ----------------------------------------------------
>
>                 Key: OAK-12114
>                 URL: https://issues.apache.org/jira/browse/OAK-12114
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: mongomk
>            Reporter: Julian Reschke
>            Assignee: Julian Reschke
>            Priority: Major
>             Fix For: 2.0.0
>
>
> ...containing only zeros, thus defeating the purpose of testing large 
> payloads.
> (actually, not testing it at all)
> With this change:
> {code}
> diff --git 
> a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
>  
> b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
> index d6e7cb264e..934af36627 100644
> --- 
> a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
> +++ 
> b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
> @@ -36,7 +36,6 @@ import org.junit.Test;
>  import org.slf4j.event.Level;
>  import java.util.ArrayList;
> -import java.util.Arrays;
>  import java.util.List;
>  import static java.util.Collections.singletonList;
> @@ -333,9 +332,5 @@ public class MongoDBExceptionTest {
>      // RED ALERT: OAK-12114
>      private String create1MBContent() {
> -        char[] chars = new char[1024 * 1024];
> -        Arrays.fill(chars, '0');
> -        String content = new String(chars);
> -        return content;
> -    }
> +        return  RandomStringUtils.secure().next(1024 * 1024);    }
>  }
> {code}
> we get
> {code}
> ERROR] Failures:
> [ERROR]   MongoDBExceptionTest.createOrUpdate16MBDoc:156
> Expected: a string containing "Document to upsert is larger than 16777216"
>      but: was "Document size of 37633707 is larger than maximum of 16793600. 
> [/foo]"
> [ERROR]   MongoDBExceptionTest.findAndUpdate16MBDoc:304
> Expected: a string containing "Resulting document after update is larger than 
> 16777216"
>      but: was "Payload document size is larger than maximum of 16793600. 
> [/foo]"
> [ERROR]   MongoDBExceptionTest.multiCreateOrUpdate16MBDoc:263
> Expected: a string containing "Resulting document after update is larger than 
> 16777216"
>      but: was "Payload document size is larger than maximum of 16793600. 
> [/test]"
> [ERROR]   MongoDBExceptionTest.update16MBDoc:231
> Expected: a string containing "Resulting document after update is larger than 
> 16777216"
>      but: was "Payload document size is larger than maximum of 16793600. 
> [/foo]"
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to