Re: Random behaviour in DataObject.find( FileObject )

Tim Boudreau <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <CA+qecRNTpqM7PNB4TjrP_-VqiaMNqAt5yycBPX2OT8x0FY9w+g@mail.gmail.com>
Looks like some kind of race condition in the mime type detection code for
XML files.  File a bug - sounds like you have a good test-case.

A workaround might be to register your own MimeResolver if the files can be
indentified by their extension, and make sure it's ordered so it comes
before the loader that resolves XML types (by sniffing the first few lines
of their content).

-Tim


On Thu, Feb 11, 2016 at 8:31 AM, Paco Barrera <[email protected]> wrote:

> Hi all,
>
> I have the next code:
>
> if (FileUtil.getMIMEType(deviceA20FO).equals("text/a20+xml")) {
>      return DataObject.find( deviceA20FO );
> } else {
>      LOGGER.warn("FileObject MIME-Type: " +
> FileUtil.getMIMEType(deviceA20FO) );
>      LOGGER.warn("FileObject content: " + deviceA20FO.asText() );
>      return null;
> }
>
>
> Randomly, sometimes this returns a good A20DataObject and others returns
> an unexpected XMLDataObject.
>
> I check that the mime-type for the FileObject is right, and always
> executes "return DataObject.find( deviceA20FO )".
>
> At this point, all depends internally of Netbeans that resolves the
> DataLoader for the FileObject mime-type, and returnsa DataObject provided
> by the DataLoader.
>
> How is it possible that sometimes resolves the right DataObject and
> sometimes bad if always right FileObject mime-type is passed?
>
> Any help is appreciated.
>



-- 
http://timboudreau.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.