[ 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/[EMAIL > PROTECTED]/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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]