abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefano Linguerri (JIRA)" <j...@apache.org>
Subject [jira] Commented: (ABDERA-170) FOMParser.parse( InputStream in, String base, ParserOptions options) throws exeception
Date Thu, 29 May 2008 12:48:45 GMT

    [ https://issues.apache.org/jira/browse/ABDERA-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12600762#action_12600762
] 

Stefano Linguerri commented on ABDERA-170:
------------------------------------------

Thanks, but the tests code is to explain better what I think it's a  bug.

Why i think it's a bug:

When I post an entry to AbderaServelt the Request pass through:

AbstractProvider.processEntry()
    --> AbstractEntityCollectionAdapter.postEntry()
        --> AbstractEntityCollectionAdapter.getEntryFromRequest()

In the AbstractEntityCollectionAdapter.getEntryFromRequest() method:

the Parser provided by Abdera is used to parse the entry:
...
     Abdera abdera = request.getAbdera();
     Parser parser = abdera.getParser();
...

The Parser returned is an instance of FOMParser.

With debbuger I see that the InputStream passes through
the method  FOMParser.parse(InputStream in, String base, ParserOptions options)
 the FOMParser at line 101 has this code:
...
    if (charset == null && options.getAutodetectCharset()) {
        FOMSniffingInputStream sin =
          (in instanceof FOMSniffingInputStream) ?
            (FOMSniffingInputStream)in :
            new FOMSniffingInputStream(in);
        charset = sin.getEncoding();
        if (charset != null) options.setCharset(charset);
        in = sin;
      }
...

So to be sure that the problem was FOMSniffingInputStream I wrote the two tests that I posted.

The test with FOMSniffingInputStream throws exception the same way as the AbderaServer.

> FOMParser.parse(    InputStream in,     String base,     ParserOptions options) throws
exeception
> -------------------------------------------------------------------------------------------------
>
>                 Key: ABDERA-170
>                 URL: https://issues.apache.org/jira/browse/ABDERA-170
>             Project: Abdera
>          Issue Type: Bug
>         Environment: linux Ubuntu 7.10, jvm Sun 1.6.0._03, abdera built from trunk source
with maven
>            Reporter: Stefano Linguerri
>         Attachments: testentry.xml
>
>
> This is on Trunk.
> The method FOMParser.parse(InputStream in, String base, ParserOptions options) use FOMSniffingInputStream
this class is the problem.
> FOMSniffingInputStream left the mark of inputstrem moved
> So when the input stream is passed to the parser an exception occurs.
> Two stupid test methods for Junit to verify the bug:
> This WORK:
>  @Test
>   public void testXMLFromFileWithoutFOMSniffingInputStream() throws Exception {
>     File file = new File("testentry.xml");
>     Abdera abdera = new Abdera();
>     FileInputStream is = new FileInputStream(file);
>     FOMParser fomParser = new FOMParser(abdera);
>     Document<Element> doc = fomParser.parse(is);
>     doc.getRoot().toString();
>   }
> This THROWS EXECEPTION
>   @Test
>   public void testXMLFromFileWithFOMSniffingInputStream() throws Exception {
>     File file = new File("testentry.xml");
>     Abdera abdera = new Abdera();
>     FileInputStream is = new FileInputStream(file);
>     FOMSniffingInputStream fomSniffingInputStream = new FOMSniffingInputStream(is);
>     fomSniffingInputStream.getEncoding();
>     FOMParser fomParser = new FOMParser(abdera);
>     Document<Element> doc = fomParser.parse(is);
>     doc.getRoot().toString();
>   }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message