Re: [Simple-support] De-serialization problem -- valid referencenot valid?
Brought to you by:
niallg
|
From: <Nia...@ub...> - 2009-02-20 13:48:44
|
Hi,
Yes this is a bug that was introduced with a recent enhancement to be
able to write primitives from Object fields and also mix primitives
within a list or map. I have resolved the issue and will release a minor
version tonight with the fix. 2.0.3.
Thanks for the feedback,
Niall
-----Original Message-----
From: Niall Gallagher [mailto:gal...@ya...]
Sent: 17 February 2009 23:33
To: sim...@li...; Alan Deikman
Subject: Re: [Simple-support] De-serialization problem -- valid
referencenot valid?
Hi,
Thanks, ill take a look.
Niall
--- On Tue, 2/17/09, Alan Deikman <Ala...@zn...> wrote:
> From: Alan Deikman <Ala...@zn...>
> Subject: Re: [Simple-support] De-serialization problem -- valid
reference not valid?
> To: sim...@li...
> Date: Tuesday, February 17, 2009, 3:10 PM Niall Gallagher wrote:
> > Is this easy to reproduce? Would it be possible to
> write a test case to expose this problem, at least then I could fix
> the issue from a known reproducable test.
> >
>
> OK, I think I have test case for you in the attached file.
> The program run without a command-line parameter will write
> the file "SimpleBug.xml". If you run it with the
> command line parameter "-r" it will try to read
> that file, with the exception. The exception I got was:
>
> org.simpleframework.xml.graph.CycleException: Invalid reference '4'
> found
>
> The file it should generate (but can't read) looks like
> this:
>
> <simpleBug id="0">
> <test1 id="1">
> <data id="2">
> <entry>
> <string
> id="3">key1</string>
> <object class="java.lang.String"
> id="4">value</object>
> </entry>
> </data>
> </test1>
> <test2 id="5">
> <data id="6">
> <entry>
> <string
> id="7">key2</string>
> <object class="java.lang.String"
> ref="4"/>
> </entry>
> </data>
> </test2>
> </simpleBug>
>
> Thanks again for this great class library.
>
> -- Alan Deikman
> ZNYX Networks
>
> /*
> * SimpleBug.java
> *
> */
>
> package com.test.teststuff;
>
> import java.io.File;
> import java.util.TreeMap;
> import org.simpleframework.xml.Element; import
> org.simpleframework.xml.ElementMap;
> import org.simpleframework.xml.Root;
> import org.simpleframework.xml.Serializer;
> import org.simpleframework.xml.core.Persister;
> import org.simpleframework.xml.core.Strategy;
> import org.simpleframework.xml.graph.CycleStrategy;
>
> /**
> *
> * @author Alan Deikman
> */
> @Root public class SimpleBug {
>
> @Element protected Mojo test1;
> @Element protected Mojo test2;
>
> public SimpleBug() {
> test1 = new Mojo();
> test1.data.put("key1",
> "value");
> test2 = new Mojo();
> test2.data.put("key2",
> "value");
> }
>
> /**
> * @param args the command line arguments
> */
> public static void main(String[] args) {
>
> SimpleBug bug = null;
>
> boolean write = true;
> if (args.length > 0 &&
> args[0].equals("-r")) write = false;
>
> Strategy resolver = new
> CycleStrategy("id", "ref");
> Serializer s = new Persister(resolver);
> File file = new File("SimpleBug.xml");
>
> if (write) {
> bug = new SimpleBug();
> try {
> s.write(bug, file);
> } catch (Exception ex) {
> System.out.println("Something went wrong.");
> }
> }
>
> else {
> try {
> bug = s.read(SimpleBug.class, file);
> } catch (Exception ex) {
> System.out.println("Can't parse");
> System.out.println(ex.toString());
> }
> }
> }
>
> public static class Mojo {
> @ElementMap protected TreeMap<String, Object> data;
> public Mojo() {
> data = new TreeMap<String, Object>();
> }
> }
>
> }
> ----------------------------------------------------------------------
> -------- Open Source Business Conference (OSBC), March 24-25, 2009,
> San Francisco, CA -OSBC tackles the biggest issue in open source: Open
> Sourcing the Enterprise -Strategies to boost innovation and cut costs
> with open source participation -Receive a $600 discount off the
> registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H__________________________________________
> _____
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
------------------------------------------------------------------------
------
Open Source Business Conference (OSBC), March 24-25, 2009, San
Francisco, CA -OSBC tackles the biggest issue in open source: Open
Sourcing the Enterprise -Strategies to boost innovation and cut costs
with open source participation -Receive a $600 discount off the
registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mails are not encrypted and cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
If verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities
or related financial instruments.
UBS Limited is a company registered in England & Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.
UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
UBS Clearing and Execution Services Limited is a company registered
in England & Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
|