jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OAK-3395) RevisionGC fails for JCR paths having line feed characters
Date Tue, 15 Sep 2015 14:41:46 GMT

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

Thomas Mueller commented on OAK-3395:
-------------------------------------

I would add randomized tests, for example:

{noformat}
EscapeUtilsTest:
    @Test
    public void randomized() throws Exception {
        Random r = new Random(1);
        for (int i = 0; i < 100000; i++) {
            int len = r.nextInt(10);
            StringBuilder buff = new StringBuilder();
            for (int j = 0; j < len; j++) {
                switch (r.nextInt(3)) {
                case 0:
                    String s = "\\\r\nrnRN ";
                    buff.append(s.charAt(r.nextInt(s.length())));
                    break;
                case 1:
                    buff.append((char) r.nextInt(300));
                    break;
                case 2:
                    buff.append((char) r.nextInt(65000));
                    break;
                }
            }
            String original = buff.toString();
            String escaped = EscapeUtils.escapeLineBreak(original);
            String unescaped = EscapeUtils.unescapeLineBreaks(escaped);
            assertTrue(escaped.indexOf('\n') < 0);
            assertTrue(escaped.indexOf('\r') < 0);
            assertEquals(original, unescaped);
        }
    }
{noformat}

> RevisionGC fails for JCR paths having line feed characters
> ----------------------------------------------------------
>
>                 Key: OAK-3395
>                 URL: https://issues.apache.org/jira/browse/OAK-3395
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: mongomk, rdbmk
>            Reporter: Chetan Mehrotra
>            Assignee: Chetan Mehrotra
>            Priority: Minor
>             Fix For: 1.3.7, 1.2.6, 1.0.21
>
>         Attachments: OAK-3395-1.patch
>
>
> RevisionGC fails with error while processing any id (derived from JCR path) having line
feed or carriage return char
> This happens because it relies on Oak Commons StringSort and ExternalSort which works
with line delimited string and having an id with line break would break this sorting logic.
Error reported is like
> {noformat}
> java.lang.AssertionError: Invalid id /1442211320
> 	at org.apache.jackrabbit.oak.plugins.document.util.Utils.getDepthFromId(Utils.java:337)
> 	at org.apache.jackrabbit.oak.plugins.document.NodeDocumentIdComparator.compare(NodeDocumentIdComparator.java:38)
> 	at org.apache.jackrabbit.oak.plugins.document.NodeDocumentIdComparator.compare(NodeDocumentIdComparator.java:30)
> 	at java.util.TimSort.countRunAndMakeAscending(TimSort.java:324)
> 	at java.util.TimSort.sort(TimSort.java:203)
> 	at java.util.TimSort.sort(TimSort.java:173)
> 	at java.util.Arrays.sort(Arrays.java:659)
> 	at java.util.Collections.sort(Collections.java:217)
> 	at org.apache.jackrabbit.oak.commons.sort.ExternalSort.sortAndSave(ExternalSort.java:279)
> 	at org.apache.jackrabbit.oak.commons.sort.ExternalSort.sortInBatch(ExternalSort.java:218)
> 	at org.apache.jackrabbit.oak.commons.sort.ExternalSort.sortInBatch(ExternalSort.java:257)
> 	at org.apache.jackrabbit.oak.commons.sort.StringSort$PersistentState.sort(StringSort.java:191)
> 	at org.apache.jackrabbit.oak.commons.sort.StringSort.sort(StringSort.java:88)
> 	at org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector$DeletedDocsGC.ensureSorted(VersionGarbageCollector.java:383)
> 	at org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector$DeletedDocsGC.getDocIdsToDelete(VersionGarbageCollector.java:274)
> 	at org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector$DeletedDocsGC.removeDeletedDocuments(VersionGarbageCollector.java:296)
> 	at org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector$DeletedDocsGC.removeDocuments(VersionGarbageCollector.java:241)
> 	at org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.collectDeletedDocuments(VersionGarbageCollector.java:154)
> 	at org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.gc(VersionGarbageCollector.java:105)
> 	at org.apache.jackrabbit.oak.plugins.document.VersionGCDeletionTest.gcWithPathsHavingNewLine(VersionGCDeletionTest.java:203)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message