You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Kelvin Goodson (JIRA)" <tu...@ws.apache.org> on 2007/10/09 12:05:50 UTC

[jira] Created: (TUSCANY-1838) HelperContext provided to createObjectOutputStream is inadvertantly ignored

HelperContext provided to createObjectOutputStream is inadvertantly ignored
---------------------------------------------------------------------------

                 Key: TUSCANY-1838
                 URL: https://issues.apache.org/jira/browse/TUSCANY-1838
             Project: Tuscany
          Issue Type: Bug
    Affects Versions: Java-SDO-1.0
            Reporter: Kelvin Goodson
             Fix For: Java-SDO-Next


Ron Gavlin reported in http://www.mail-archive.com/tuscany-user@ws.apache.org/msg01884.html an issue with HelperContexts being unavailable during marshalling.  I feel sure that this is due to this piece of code here in HelperProviderBase::ResolvableImpl#writeDataObject


        XMLHelper xmlHelperLocal = xmlHelper;
        if(objectOutput instanceof SDOObjectInputStream)
        {
            xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper();
        }
        xmlHelperLocal.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream);

where the instanceof test and cast should be to SDOObjectOutputStream


-- 
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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Commented: (TUSCANY-1838) HelperContext provided to createObjectOutputStream is inadvertantly ignored

Posted by "Ron Gavlin (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533409 ] 

Ron Gavlin commented on TUSCANY-1838:
-------------------------------------

Hi Kelvin,

Thanks for looking into this problem. I am bogged down working through TUSCANY-1832 right now. I'll take a look at this afterwards.

Thanks again,

- Ron

> HelperContext provided to createObjectOutputStream is inadvertantly ignored
> ---------------------------------------------------------------------------
>
>                 Key: TUSCANY-1838
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1838
>             Project: Tuscany
>          Issue Type: Bug
>    Affects Versions: Java-SDO-1.0
>            Reporter: Kelvin Goodson
>             Fix For: Java-SDO-Next
>
>
> Ron Gavlin reported in http://www.mail-archive.com/tuscany-user@ws.apache.org/msg01884.html an issue with HelperContexts being unavailable during marshalling.  I feel sure that this is due to this piece of code here in HelperProviderBase::ResolvableImpl#writeDataObject
>         XMLHelper xmlHelperLocal = xmlHelper;
>         if(objectOutput instanceof SDOObjectInputStream)
>         {
>             xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper();
>         }
>         xmlHelperLocal.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream);
> where the instanceof test and cast should be to SDOObjectOutputStream

-- 
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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Updated: (TUSCANY-1838) HelperContext provided to createObjectOutputStream is inadvertantly ignored

Posted by "Amita Vadhavkar (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Amita Vadhavkar updated TUSCANY-1838:
-------------------------------------

      Component/s: Java SDO Implementation
    Fix Version/s:     (was: Java-SDO-Next)
                   Java-SDO-1.1

> HelperContext provided to createObjectOutputStream is inadvertantly ignored
> ---------------------------------------------------------------------------
>
>                 Key: TUSCANY-1838
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1838
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-1.0
>            Reporter: Kelvin Goodson
>             Fix For: Java-SDO-1.1
>
>
> Ron Gavlin reported in http://www.mail-archive.com/tuscany-user@ws.apache.org/msg01884.html an issue with HelperContexts being unavailable during marshalling.  I feel sure that this is due to this piece of code here in HelperProviderBase::ResolvableImpl#writeDataObject
>         XMLHelper xmlHelperLocal = xmlHelper;
>         if(objectOutput instanceof SDOObjectInputStream)
>         {
>             xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper();
>         }
>         xmlHelperLocal.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream);
> where the instanceof test and cast should be to SDOObjectOutputStream

-- 
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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Resolved: (TUSCANY-1838) HelperContext provided to createObjectOutputStream is inadvertantly ignored

Posted by "Amita Vadhavkar (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Amita Vadhavkar resolved TUSCANY-1838.
--------------------------------------

    Resolution: Fixed

Marking resolved based on the previous comment. If required please provide a test case which demonstrates the failure and reopen the JIRA if necessary.

> HelperContext provided to createObjectOutputStream is inadvertantly ignored
> ---------------------------------------------------------------------------
>
>                 Key: TUSCANY-1838
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1838
>             Project: Tuscany
>          Issue Type: Bug
>    Affects Versions: Java-SDO-1.0
>            Reporter: Kelvin Goodson
>             Fix For: Java-SDO-Next
>
>
> Ron Gavlin reported in http://www.mail-archive.com/tuscany-user@ws.apache.org/msg01884.html an issue with HelperContexts being unavailable during marshalling.  I feel sure that this is due to this piece of code here in HelperProviderBase::ResolvableImpl#writeDataObject
>         XMLHelper xmlHelperLocal = xmlHelper;
>         if(objectOutput instanceof SDOObjectInputStream)
>         {
>             xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper();
>         }
>         xmlHelperLocal.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream);
> where the instanceof test and cast should be to SDOObjectOutputStream

-- 
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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Commented: (TUSCANY-1838) HelperContext provided to createObjectOutputStream is inadvertantly ignored

Posted by "Amita Vadhavkar (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566049#action_12566049 ] 

Amita Vadhavkar commented on TUSCANY-1838:
------------------------------------------

See below analysis of what I understood so far - conclusion from that - Kelvin's fix in http://svn.apache.org/viewvc?rev=583095&view=rev
is correct even though it is irrelevant for the below as well as for Ron's test condition.

HelperProviderBase is abstract but HelperProviderImpl does provide required Helpers. When the call comes to 
Resolvable.writeExternal(ObjectOutput) and when target in Resolvable is set to a DataObject - 
HelperProvideBase.ResolvableImpl.writeDataObject(DataObject dataObject, ObjectOutput objectOutput) is called.
In this if DataObject(target) does not have a DataGraph and does not have a container, xmlHelperLocal is assigned
from instance member xmlHelper. As HelperProviderImpl does provide all Helpers, at this point xmlHelper should be
not null. Further as a special case, if ObjectOutput is instance of SDOObjectOutputStream, its HelperContext is used
and so xmlHelperLocal take value from it. But if ObjectOutput is not instance of SDOObjectOutputStream, the xmlHelper
already obtained from HelperProviderImpl will hold good. So it will be "available".  

To further verify this, I wrote a small test case like below - please note - quote.detach();//to make sure data graph and container are null
****************************************************************
	public void testWriteDataObject() throws Exception {
	URL url = getClass().getResource("/simple.xsd");
        InputStream inputStream = url.openStream();
        XSDHelper.INSTANCE.define(inputStream, url.toString());
        inputStream.close();
        
	DataGraph dataGraph = SDOUtil.createDataGraph();
        Type quoteType = dataGraph.getType("http://www.example.com/simple", "Quote");
        DataObject quote = dataGraph.createRootObject(quoteType);
        quote.setString("symbol", "HP");
        System.out.println("before detach:"+XMLHelper.INSTANCE.save(quote, "quote", "quote"));
        
        quote.detach();//***to make sure data graph and container are null
        
        System.out.println("after detach:"+XMLHelper.INSTANCE.save(quote, "quote", "quote"));
        
        ByteArrayOutputStream compressedByteArrayOutputStream = new ByteArrayOutputStream();
        GZIPOutputStream gzipOutputStream = new GZIPOutputStream(compressedByteArrayOutputStream);
        XMLHelper.INSTANCE.save(quote, "commonj.sdo", "dataObject", gzipOutputStream);
        gzipOutputStream.close(); // Flush the contents
        System.out.println("byes in target DO..being written:"+compressedByteArrayOutputStream.toByteArray().length);
        		        
	HelperProvider hp = HelperProvider.getInstance();
	if(hp instanceof HelperProviderBase) {
		HelperProviderBase hpb = (HelperProviderBase)hp;
		Resolvable resolvable = hpb.resolvable(quote);

		FileOutputStream fos = new FileOutputStream("c:/test123.txt");

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ObjectOutputStream oos = new ObjectOutputStream(baos);

		resolvable.writeExternal(oos);
		oos.flush();

		byte[] writtenDOBytes = baos.toByteArray();
		fos.write(writtenDOBytes);
		fos.flush();
		fos.close();

		System.out.println("Reading Now.......");

		FileInputStream fis = new FileInputStream("c:/test123.txt");
		ObjectInputStream ois = new ObjectInputStream(fis);
		byte firstByte = ois.readByte();
		System.out.println("firstByte:"+firstByte);
		int nextInt = ois.readInt();
		System.out.println("nextInt-length:"+nextInt);
		int idx = 0;
		byte[] readRemainingBytes = new byte[1000];

		while(true) {
			try{
				readRemainingBytes[idx] = ois.readByte();
				//System.out.println("read byte:"+idx);
				idx++;
			} catch(Exception e) {
				//e.printStackTrace();
				break;
			}
		}

		String stringOfDO = new String(readRemainingBytes, 0, idx);			
		System.out.println("stringOfDOBytes length:"+stringOfDO.length());			
	}
	
	}
****************************************************************
Output

before detach:<?xml version="1.0" encoding="UTF-8"?>
<quote:quote xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:quote="quote"
    xmlns:simple="http://www.example.com/simple" xsi:type="simple:Quote">
  <symbol>HP</symbol>
</quote:quote>
after detach:<?xml version="1.0" encoding="UTF-8"?>
<quote:quote xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:quote="quote"
    xmlns:simple="http://www.example.com/simple" xsi:type="simple:Quote">
  <symbol>HP</symbol>
</quote:quote>
byes in target DO..being written:199
Reading Now.......
firstByte:1
nextInt-length:199
stringOfDOBytes length:199
****************************************************************
In above test ByteArrayOutputStream was not instance of SDOObjectOutputStream and still xmlHelper was available.
Will you please provide a test case to demonstrate the exact failure/xmlHelper unavailability?  Ot else shall we mark
this JIRA Resolved/Fixed?

Regards,
Amita


> HelperContext provided to createObjectOutputStream is inadvertantly ignored
> ---------------------------------------------------------------------------
>
>                 Key: TUSCANY-1838
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1838
>             Project: Tuscany
>          Issue Type: Bug
>    Affects Versions: Java-SDO-1.0
>            Reporter: Kelvin Goodson
>             Fix For: Java-SDO-Next
>
>
> Ron Gavlin reported in http://www.mail-archive.com/tuscany-user@ws.apache.org/msg01884.html an issue with HelperContexts being unavailable during marshalling.  I feel sure that this is due to this piece of code here in HelperProviderBase::ResolvableImpl#writeDataObject
>         XMLHelper xmlHelperLocal = xmlHelper;
>         if(objectOutput instanceof SDOObjectInputStream)
>         {
>             xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper();
>         }
>         xmlHelperLocal.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream);
> where the instanceof test and cast should be to SDOObjectOutputStream

-- 
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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Commented: (TUSCANY-1838) HelperContext provided to createObjectOutputStream is inadvertantly ignored

Posted by "Ron Gavlin (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534053 ] 

Ron Gavlin commented on TUSCANY-1838:
-------------------------------------

Kelvin,

In my case, objectOutput is an instance of IIOPOutputStream and not SDOObjectOutputStream which makes your change irrelevant.

- Ron

> HelperContext provided to createObjectOutputStream is inadvertantly ignored
> ---------------------------------------------------------------------------
>
>                 Key: TUSCANY-1838
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1838
>             Project: Tuscany
>          Issue Type: Bug
>    Affects Versions: Java-SDO-1.0
>            Reporter: Kelvin Goodson
>             Fix For: Java-SDO-Next
>
>
> Ron Gavlin reported in http://www.mail-archive.com/tuscany-user@ws.apache.org/msg01884.html an issue with HelperContexts being unavailable during marshalling.  I feel sure that this is due to this piece of code here in HelperProviderBase::ResolvableImpl#writeDataObject
>         XMLHelper xmlHelperLocal = xmlHelper;
>         if(objectOutput instanceof SDOObjectInputStream)
>         {
>             xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper();
>         }
>         xmlHelperLocal.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream);
> where the instanceof test and cast should be to SDOObjectOutputStream

-- 
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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Commented: (TUSCANY-1838) HelperContext provided to createObjectOutputStream is inadvertantly ignored

Posted by "Kelvin Goodson (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533327 ] 

Kelvin Goodson commented on TUSCANY-1838:
-----------------------------------------

I made a fix in http://svn.apache.org/viewvc?rev=583095&view=rev

Could you see if this fixes your issue please?

> HelperContext provided to createObjectOutputStream is inadvertantly ignored
> ---------------------------------------------------------------------------
>
>                 Key: TUSCANY-1838
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1838
>             Project: Tuscany
>          Issue Type: Bug
>    Affects Versions: Java-SDO-1.0
>            Reporter: Kelvin Goodson
>             Fix For: Java-SDO-Next
>
>
> Ron Gavlin reported in http://www.mail-archive.com/tuscany-user@ws.apache.org/msg01884.html an issue with HelperContexts being unavailable during marshalling.  I feel sure that this is due to this piece of code here in HelperProviderBase::ResolvableImpl#writeDataObject
>         XMLHelper xmlHelperLocal = xmlHelper;
>         if(objectOutput instanceof SDOObjectInputStream)
>         {
>             xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper();
>         }
>         xmlHelperLocal.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream);
> where the instanceof test and cast should be to SDOObjectOutputStream

-- 
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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org