You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Andrey Belyaev (JIRA)" <xm...@xml.apache.org> on 2008/04/24 12:43:22 UTC

[jira] Updated: (XMLBEANS-371) Method parse is not reenterable

     [ 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