[prev in list] [next in list] [prev in thread] [next in thread]
List: xmlbeans-dev
Subject: [jira] Updated: (XMLBEANS-371) Method parse is not reenterable
From: "Andrey Belyaev (JIRA)" <xmlbeans-dev () xml ! apache ! org>
Date: 2008-04-24 10:43:22
Message-ID: 618461933.1209033802426.JavaMail.jira () brutus
[Download RAW message or body]
[ https://issues.apache.org/jira/browse/XMLBEANS-371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]
Andrey Belyaev updated XMLBEANS-371:
------------------------------------
Description:
I have a realisation of InputStream. The "read" method of this class parses some \
xml. When I try to parse xml from this stream i've got an error:
java.lang.NullPointerException
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3483)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:663)
at xmlbeanssyscachetest.XmlBeansSysCacheTest.main(XmlBeansSysCacheTest.java:32)
The error caused by using the same instance of SaxParser in inner and outter parse \
processes. After the end of inner parse the parser is closed but the outter parse \
proceeds use it.
We tried to solve the problem by overriding the \
org.apache.xmlbeans.impl.common.SystemCache class but it's also done in \
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl class. So this variant is not \
safe enougth.
Sample:
package xmlbeanssyscachetest;
import java.io.ByteArrayInputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.xmlbeans.XmlObject;
public class XmlBeansSysCacheTest {
static class TestInputStream extends ByteArrayInputStream{
private static byte[] data = "<?xml version=\"1.0\" \
encoding=\"UTF-8\"?><test/>".getBytes();
public TestInputStream() {
super(data);
}
@Override
public synchronized int read(byte b[], int off, int len) {
try { //do some parse during other (outter) parse
XmlObject x = XmlObject.Factory.parse(new ByteArrayInputStream(data));
System.out.println(x.xmlText());
} catch (Exception ex) {
Logger.getLogger(XmlBeansSysCacheTest.class.getName()).log(Level.SEVERE, null, ex);
}
return super.read(b, off, len);
}
}
public static void main(String[] args) {
try {
XmlObject x = XmlObject.Factory.parse(new TestInputStream());
} catch (Exception ex) {
Logger.getLogger(XmlBeansSysCacheTest.class.getName()).log(Level.SEVERE, null, \
ex); }
}
}
was:
I have a realisation of InputStream. The "read" method of this class parses some \
xml. When I try to parse xml from this stream i've got an error:
java.lang.NullPointerException
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3483)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:663)
at xmlbeanssyscachetest.XmlBeansSysCacheTest.main(XmlBeansSysCacheTest.java:32)
The error caused by using the same instance of SaxParser in inner and outter parse \
processes. After the end of inner parse the parser is closed but the outter parse \
proceeds use it.
We tried to solve the problem by overriding of the \
org.apache.xmlbeans.impl.common.SystemCache class but it's also done in \
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl class. So this variant is not \
safe enougth.
Sample:
package xmlbeanssyscachetest;
import java.io.ByteArrayInputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.xmlbeans.XmlObject;
public class XmlBeansSysCacheTest {
static class TestInputStream extends ByteArrayInputStream{
private static byte[] data = "<?xml version=\"1.0\" \
encoding=\"UTF-8\"?><test/>".getBytes();
public TestInputStream() {
super(data);
}
@Override
public synchronized int read(byte b[], int off, int len) {
try { //do some parse during other (outter) parse
XmlObject x = XmlObject.Factory.parse(new ByteArrayInputStream(data));
System.out.println(x.xmlText());
} catch (Exception ex) {
Logger.getLogger(XmlBeansSysCacheTest.class.getName()).log(Level.SEVERE, null, ex);
}
return super.read(b, off, len);
}
}
public static void main(String[] args) {
try {
XmlObject x = XmlObject.Factory.parse(new TestInputStream());
} catch (Exception ex) {
Logger.getLogger(XmlBeansSysCacheTest.class.getName()).log(Level.SEVERE, null, \
ex); }
}
}
> Method parse is not reenterable
> -------------------------------
>
> Key: XMLBEANS-371
> URL: https://issues.apache.org/jira/browse/XMLBEANS-371
> Project: XMLBeans
> Issue Type: Bug
> Affects Versions: Version 2.3.1
> Reporter: Andrey Belyaev
>
> I have a realisation of InputStream. The "read" method of this class parses some \
> xml. When I try to parse xml from this stream i've got an error:
> java.lang.NullPointerException
> at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3483)
> at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
> at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
> at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
> at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:663)
> at xmlbeanssyscachetest.XmlBeansSysCacheTest.main(XmlBeansSysCacheTest.java:32)
> The error caused by using the same instance of SaxParser in inner and outter parse \
> processes. After the end of inner parse the parser is closed but the outter parse \
> proceeds use it. We tried to solve the problem by overriding the \
> org.apache.xmlbeans.impl.common.SystemCache class but it's also done in \
> org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl class. So this variant is not \
> safe enougth. Sample:
> package xmlbeanssyscachetest;
> import java.io.ByteArrayInputStream;
> import java.util.logging.Level;
> import java.util.logging.Logger;
> import org.apache.xmlbeans.XmlObject;
> public class XmlBeansSysCacheTest {
> static class TestInputStream extends ByteArrayInputStream{
>
> private static byte[] data = "<?xml version=\"1.0\" \
> encoding=\"UTF-8\"?><test/>".getBytes(); public TestInputStream() {
> super(data);
> }
> @Override
> public synchronized int read(byte b[], int off, int len) {
> try { //do some parse during other (outter) parse
> XmlObject x = XmlObject.Factory.parse(new ByteArrayInputStream(data));
> System.out.println(x.xmlText());
> } catch (Exception ex) {
> Logger.getLogger(XmlBeansSysCacheTest.class.getName()).log(Level.SEVERE, null, \
> ex); }
> return super.read(b, off, len);
> }
>
> }
>
> public static void main(String[] args) {
> try {
> XmlObject x = XmlObject.Factory.parse(new TestInputStream());
> } catch (Exception ex) {
> Logger.getLogger(XmlBeansSysCacheTest.class.getName()).log(Level.SEVERE, null, \
> ex); }
> }
> }
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic