You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Svatopluk Šperka (JIRA)" <ji...@apache.org> on 2012/11/15 16:24:12 UTC

[jira] [Created] (JENA-347) NodecSSE decode problem

Svatopluk Šperka created JENA-347:
-------------------------------------

             Summary: NodecSSE decode problem
                 Key: JENA-347
                 URL: https://issues.apache.org/jira/browse/JENA-347
             Project: Apache Jena
          Issue Type: Bug
          Components: TDB
    Affects Versions: TDB 0.9.1
         Environment: Confirmed in Scala REPL
            Reporter: Svatopluk Šperka
            Priority: Minor


Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
if ( str.startsWith("<") )
        {
            // Do directly.
            // (is it quicker?)
            str = str.trim(); // !!!!!!!!!!! this line inserted
            str = str.substring(1,str.length()-1) ;
            str = StrUtils.unescapeString(str) ;
            str = StrUtils.decodeHex(str, MarkerChar) ;
            return Node.createURI(str) ;
        }

I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (JENA-347) NodecSSE decode problem

Posted by "Svatopluk Šperka (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Svatopluk Šperka updated JENA-347:
----------------------------------

    Affects Version/s: TDB 0.9.4
    
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1, TDB 0.9.4
>         Environment: Confirmed in Scala REPL
>            Reporter: Svatopluk Šperka
>            Priority: Minor
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (JENA-347) NodecSSE decode problem

Posted by "Andy Seaborne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499478#comment-13499478 ] 

Andy Seaborne commented on JENA-347:
------------------------------------

I'm afraid that your code makes an unwarranted assumption.

A ByterBuffer has a limit that indicates which part is in-use and which part isn't.  This is lost when you do buffer.array -- the backing array is all the space of the buffer (caution - it may also throw UnsupportedOperationException).

When you do ByteBuffer.wrap, the limit is set to the maximum -- and that includes bytes outside space used to encoded the URI.  maxSize is an upper bound and is done without inspecting the node other than it's type.

The use of str.trim is removing nulls caused by the inclusion of null bytes.

Try this:

      val bytesUsed = buffer.limit()
      val encodedInArray = buffer.array
      val bb = ByteBuffer.wrap( encodedInArray )
      bb.limit(bytesUsed)
      bb.position(0)
      val decodedFromArray = n.decode( bb, null )

                
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1, TDB 0.9.4
>         Environment: Confirmed in Scala 2.9.2 REPL
>            Reporter: Svatopluk Šperka
>            Priority: Minor
>         Attachments: NodecSSEProof.scala
>
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (JENA-347) NodecSSE decode problem

Posted by "Andy Seaborne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498095#comment-13498095 ] 

Andy Seaborne commented on JENA-347:
------------------------------------

PS Some unfinished code to do streams of Tuples of Turtle terms:
https://svn.apache.org/repos/asf/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/io/
                
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1
>         Environment: Confirmed in Scala REPL
>            Reporter: Svatopluk Šperka
>            Priority: Minor
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (JENA-347) NodecSSE decode problem

Posted by "Svatopluk Šperka (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Svatopluk Šperka updated JENA-347:
----------------------------------

    Environment: Confirmed in Scala 2.9.2 REPL  (was: Confirmed in Scala REPL)
    
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1, TDB 0.9.4
>         Environment: Confirmed in Scala 2.9.2 REPL
>            Reporter: Svatopluk Šperka
>            Priority: Minor
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Closed] (JENA-347) NodecSSE decode problem

Posted by "Andy Seaborne (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Seaborne closed JENA-347.
------------------------------

    
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1, TDB 0.9.4
>         Environment: Confirmed in Scala 2.9.2 REPL
>            Reporter: Svatopluk Šperka
>            Assignee: Andy Seaborne
>            Priority: Minor
>         Attachments: NodecSSEProof.scala
>
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (JENA-347) NodecSSE decode problem

Posted by "Svatopluk Šperka (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Svatopluk Šperka updated JENA-347:
----------------------------------

    Attachment: NodecSSEProof.scala

Short code showing that encoding Node_URI into array through ByteBuffer and creating Node_URI from this array by the reversed process results in URI that is not equal to the original one.
                
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1, TDB 0.9.4
>         Environment: Confirmed in Scala 2.9.2 REPL
>            Reporter: Svatopluk Šperka
>            Priority: Minor
>         Attachments: NodecSSEProof.scala
>
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (JENA-347) NodecSSE decode problem

Posted by "Andy Seaborne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498089#comment-13498089 ] 

Andy Seaborne commented on JENA-347:
------------------------------------

Please try the current release (0.9.4).  There have been fixes in this area.

But NodecSSE does not create strings with leading or trailing spaces.  How did the problematic string get created in the first place?


                
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1
>         Environment: Confirmed in Scala REPL
>            Reporter: Svatopluk Šperka
>            Priority: Minor
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (JENA-347) NodecSSE decode problem

Posted by "Andy Seaborne (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Seaborne resolved JENA-347.
--------------------------------

    Resolution: Not A Problem
      Assignee: Andy Seaborne
    
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1, TDB 0.9.4
>         Environment: Confirmed in Scala 2.9.2 REPL
>            Reporter: Svatopluk Šperka
>            Assignee: Andy Seaborne
>            Priority: Minor
>         Attachments: NodecSSEProof.scala
>
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (JENA-347) NodecSSE decode problem

Posted by "Svatopluk Šperka (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499028#comment-13499028 ] 

Svatopluk Šperka edited comment on JENA-347 at 11/16/12 7:17 PM:
-----------------------------------------------------------------

I've attached the short Scala code showing that encoding Node_URI into array through ByteBuffer and creating Node_URI from this array by the reversed process results in URI that is not equal to the original one. 

Just run by "scala NodecSSEProof.scala".
                
      was (Author: beho):
    Short code showing that encoding Node_URI into array through ByteBuffer and creating Node_URI from this array by the reversed process results in URI that is not equal to the original one.
                  
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1, TDB 0.9.4
>         Environment: Confirmed in Scala 2.9.2 REPL
>            Reporter: Svatopluk Šperka
>            Priority: Minor
>         Attachments: NodecSSEProof.scala
>
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (JENA-347) NodecSSE decode problem

Posted by "Andy Seaborne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JENA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498089#comment-13498089 ] 

Andy Seaborne edited comment on JENA-347 at 11/15/12 4:27 PM:
--------------------------------------------------------------

Please try the current release (0.9.4).  There have been fixes in this area.

But NodecSSE does not create strings with leading or trailing spaces.  How did the problematic string get created in the first place?  Previously illegal IRIs (e.g. spaces, and intemal <> characters) could confuse the process.


                
      was (Author: andy.seaborne):
    Please try the current release (0.9.4).  There have been fixes in this area.

But NodecSSE does not create strings with leading or trailing spaces.  How did the problematic string get created in the first place?


                  
> NodecSSE decode problem
> -----------------------
>
>                 Key: JENA-347
>                 URL: https://issues.apache.org/jira/browse/JENA-347
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1
>         Environment: Confirmed in Scala REPL
>            Reporter: Svatopluk Šperka
>            Priority: Minor
>
> Decode method of NodecSSE should be the inverse function of encode but it's not. In case of URI, decode create NodeURI from the string obtained from the whole ByteBuffer passed to decode. This results in URL that is not equal to the original URI (it's longer as it contains nonsensical suffix). I've temporarily fixed that by trimming the decoded string before creating URI:
> if ( str.startsWith("<") )
>         {
>             // Do directly.
>             // (is it quicker?)
>             str = str.trim(); // !!!!!!!!!!! this line inserted
>             str = str.substring(1,str.length()-1) ;
>             str = StrUtils.unescapeString(str) ;
>             str = StrUtils.decodeHex(str, MarkerChar) ;
>             return Node.createURI(str) ;
>         }
> I'm using NodecSSE to encode Nodes in order to transfer them through network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira