Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHow to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/483877/#msg_483877
I'm trying to read an EMF resource. In case it does not exist, I create a
new one, add some default content to it and call save().
Now I've got the problem, that after the save(), the resource might still
not exist and an IOException is thrown when I try to load the resource. It
seems like a race condition to me, since it never occurs in the debugger.
So I helped myself with the following loop:
while
(!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
Collections.EMPTY_MAP))
{
System.out.println("save it");
resource.save(saveOptions);
}
It is now clear, that save() does not guarantee the existence of the
resource after it has been called. I have seen up to 30 executions of the
while-loop until the resource finally existed.
My question is: how can I make sure, that the new resource really exists?
The while-loop does not look like a nice solution to me. Or am I
misunderstanding something?
Thanks for your helpful posts ;-)
Roland]]>Roland Brand2009-09-03T13:00:16-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/617812/#msg_617812
Please post EMF questions to the EMF newsgroup, which I've added to the
"to" list of the reply. More comments below.
Roland Brand wrote:
> Hi all
>
> I'm trying to read an EMF resource. In case it does not exist, I
> create a new one, add some default content to it and call save().
>
> Now I've got the problem, that after the save(), the resource might
> still not exist and an IOException is thrown when I try to load the
> resource. It seems like a race condition to me, since it never occurs
> in the debugger. So I helped myself with the following loop:
>
> while
> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
> Collections.EMPTY_MAP))
> {
> System.out.println("save it");
> resource.save(saveOptions);
> }
>
> It is now clear, that save() does not guarantee the existence of the
> resource after it has been called. I have seen up to 30 executions of
> the while-loop until the resource finally existed.
What's the value of the URI?
>
> My question is: how can I make sure, that the new resource really
> exists? The while-loop does not look like a nice solution to me. Or am
> I misunderstanding something?
I wouldn't expect this kind of behavior...
>
>
> Thanks for your helpful posts ;-)
>
> Roland
>]]>Ed Merks2009-09-03T20:36:59-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/483995/#msg_483995
Please post EMF questions to the EMF newsgroup, which I've added to the
"to" list of the reply. More comments below.
Roland Brand wrote:
> Hi all
>
> I'm trying to read an EMF resource. In case it does not exist, I
> create a new one, add some default content to it and call save().
>
> Now I've got the problem, that after the save(), the resource might
> still not exist and an IOException is thrown when I try to load the
> resource. It seems like a race condition to me, since it never occurs
> in the debugger. So I helped myself with the following loop:
>
> while
> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
> Collections.EMPTY_MAP))
> {
> System.out.println("save it");
> resource.save(saveOptions);
> }
>
> It is now clear, that save() does not guarantee the existence of the
> resource after it has been called. I have seen up to 30 executions of
> the while-loop until the resource finally existed.
What's the value of the URI?
>
> My question is: how can I make sure, that the new resource really
> exists? The while-loop does not look like a nice solution to me. Or am
> I misunderstanding something?
I wouldn't expect this kind of behavior...
>
>
> Thanks for your helpful posts ;-)
>
> Roland
>]]>Ed Merks2009-09-03T20:36:59-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/617814/#msg_617814
Ed Merks wrote:
> Please post EMF questions to the EMF newsgroup, which I've added to the
> "to" list of the reply. More comments below.
Oops, sorry.
> Roland Brand wrote:
>> Hi all
>>
>> I'm trying to read an EMF resource. In case it does not exist, I
>> create a new one, add some default content to it and call save().
>>
>> Now I've got the problem, that after the save(), the resource might
>> still not exist and an IOException is thrown when I try to load the
>> resource. It seems like a race condition to me, since it never occurs
>> in the debugger. So I helped myself with the following loop:
>>
>> while
>> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
>> Collections.EMPTY_MAP))
>> {
>> System.out.println("save it");
>> resource.save(saveOptions);
>> }
>>
>> It is now clear, that save() does not guarantee the existence of the
>> resource after it has been called. I have seen up to 30 executions of
>> the while-loop until the resource finally existed.
> What's the value of the URI?
As you can probably guess, I have a Zipfile containing GMF resources: a
semantic model and a notation model.
>>
>> My question is: how can I make sure, that the new resource really
>> exists? The while-loop does not look like a nice solution to me. Or am
>> I misunderstanding something?
> I wouldn't expect this kind of behavior...
>>
>>
>> Thanks for your helpful posts ;-)
>>
>> Roland
>>]]>Roland Brand2009-09-04T07:02:44-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/484060/#msg_484060
Ed Merks wrote:
> Please post EMF questions to the EMF newsgroup, which I've added to the
> "to" list of the reply. More comments below.
Oops, sorry.
> Roland Brand wrote:
>> Hi all
>>
>> I'm trying to read an EMF resource. In case it does not exist, I
>> create a new one, add some default content to it and call save().
>>
>> Now I've got the problem, that after the save(), the resource might
>> still not exist and an IOException is thrown when I try to load the
>> resource. It seems like a race condition to me, since it never occurs
>> in the debugger. So I helped myself with the following loop:
>>
>> while
>> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
>> Collections.EMPTY_MAP))
>> {
>> System.out.println("save it");
>> resource.save(saveOptions);
>> }
>>
>> It is now clear, that save() does not guarantee the existence of the
>> resource after it has been called. I have seen up to 30 executions of
>> the while-loop until the resource finally existed.
> What's the value of the URI?
As you can probably guess, I have a Zipfile containing GMF resources: a
semantic model and a notation model.
>>
>> My question is: how can I make sure, that the new resource really
>> exists? The while-loop does not look like a nice solution to me. Or am
>> I misunderstanding something?
> I wouldn't expect this kind of behavior...
>>
>>
>> Thanks for your helpful posts ;-)
>>
>> Roland
>>]]>Roland Brand2009-09-04T07:02:44-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/617816/#msg_617816
Perhaps there is a bug in exists for this case. If you could create a
test case demonstrating the problem in a bugzilla report, I'll quickly
have a look and fix it if there is a basic problem.
Roland Brand wrote:
> Hi Ed
>
> Ed Merks wrote:
>> Please post EMF questions to the EMF newsgroup, which I've added to
>> the "to" list of the reply. More comments below.
>
> Oops, sorry.
>
>
>> Roland Brand wrote:
>>> Hi all
>>>
>>> I'm trying to read an EMF resource. In case it does not exist, I
>>> create a new one, add some default content to it and call save().
>>>
>>> Now I've got the problem, that after the save(), the resource might
>>> still not exist and an IOException is thrown when I try to load the
>>> resource. It seems like a race condition to me, since it never
>>> occurs in the debugger. So I helped myself with the following loop:
>>>
>>> while
>>> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
>>> Collections.EMPTY_MAP))
>>> {
>>> System.out.println("save it");
>>> resource.save(saveOptions);
>>> }
>>>
>>> It is now clear, that save() does not guarantee the existence of the
>>> resource after it has been called. I have seen up to 30 executions
>>> of the while-loop until the resource finally existed.
>> What's the value of the URI?
>
> The URI is archive:file://home/rbrand/model.zip!/semantic.xmi
>
> As you can probably guess, I have a Zipfile containing GMF resources:
> a semantic model and a notation model.
>
>>>
>>> My question is: how can I make sure, that the new resource really
>>> exists? The while-loop does not look like a nice solution to me. Or
>>> am I misunderstanding something?
>> I wouldn't expect this kind of behavior...
>>>
>>>
>>> Thanks for your helpful posts ;-)
>>>
>>> Roland
>>>
>
>]]>Ed Merks2009-09-04T15:05:04-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/484200/#msg_484200
Perhaps there is a bug in exists for this case. If you could create a
test case demonstrating the problem in a bugzilla report, I'll quickly
have a look and fix it if there is a basic problem.
Roland Brand wrote:
> Hi Ed
>
> Ed Merks wrote:
>> Please post EMF questions to the EMF newsgroup, which I've added to
>> the "to" list of the reply. More comments below.
>
> Oops, sorry.
>
>
>> Roland Brand wrote:
>>> Hi all
>>>
>>> I'm trying to read an EMF resource. In case it does not exist, I
>>> create a new one, add some default content to it and call save().
>>>
>>> Now I've got the problem, that after the save(), the resource might
>>> still not exist and an IOException is thrown when I try to load the
>>> resource. It seems like a race condition to me, since it never
>>> occurs in the debugger. So I helped myself with the following loop:
>>>
>>> while
>>> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
>>> Collections.EMPTY_MAP))
>>> {
>>> System.out.println("save it");
>>> resource.save(saveOptions);
>>> }
>>>
>>> It is now clear, that save() does not guarantee the existence of the
>>> resource after it has been called. I have seen up to 30 executions
>>> of the while-loop until the resource finally existed.
>> What's the value of the URI?
>
> The URI is archive:file://home/rbrand/model.zip!/semantic.xmi
>
> As you can probably guess, I have a Zipfile containing GMF resources:
> a semantic model and a notation model.
>
>>>
>>> My question is: how can I make sure, that the new resource really
>>> exists? The while-loop does not look like a nice solution to me. Or
>>> am I misunderstanding something?
>> I wouldn't expect this kind of behavior...
>>>
>>>
>>> Thanks for your helpful posts ;-)
>>>
>>> Roland
>>>
>
>]]>Ed Merks2009-09-04T15:05:04-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/484352/#msg_484352
I think the exists() is working properly. When I omit the while-loop and
call resource.save() only once, I get an IOException when I try to read
the resource. It really does not exists for a short amount of time.
java.io.IOException: Archive entry not found archive:file://home/rbrand/model.zip!/semantic.xmi
at
org.eclipse.emf.common.archive.ArchiveURLConnection.getInput Stream(ArchiveURLConnection.java:244)
at
org.eclipse.emf.ecore.resource.impl.ArchiveURIHandlerImpl.cr eateInputStream(ArchiveURIHandlerImpl.java:59)
at
org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterIm pl.createInputStream(ExtensibleURIConverterImpl.java:301)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1254)
Stepping into the resource.save() I could see that the OutputStream is
closed. But nevertheless it seems not to be written to disk directly.
Could there be OS caches? Is there a possiblity to flush the Zipfile?]]>Roland Brand2009-09-07T07:47:20-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/617818/#msg_617818
I think the exists() is working properly. When I omit the while-loop and
call resource.save() only once, I get an IOException when I try to read
the resource. It really does not exists for a short amount of time.
java.io.IOException: Archive entry not found archive:file://home/rbrand/model.zip!/semantic.xmi
at
org.eclipse.emf.common.archive.ArchiveURLConnection.getInput Stream(ArchiveURLConnection.java:244)
at
org.eclipse.emf.ecore.resource.impl.ArchiveURIHandlerImpl.cr eateInputStream(ArchiveURIHandlerImpl.java:59)
at
org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterIm pl.createInputStream(ExtensibleURIConverterImpl.java:301)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1254)
Stepping into the resource.save() I could see that the OutputStream is
closed. But nevertheless it seems not to be written to disk directly.
Could there be OS caches? Is there a possiblity to flush the Zipfile?]]>Roland Brand2009-09-07T07:47:20-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/484435/#msg_484435
It could well be an OS issue I suppose... I'm just not sure what to do
about it...
Roland Brand wrote:
> Hi Ed
>
> I think the exists() is working properly. When I omit the while-loop
> and call resource.save() only once, I get an IOException when I try to
> read the resource. It really does not exists for a short amount of time.
>
> java.io.IOException: Archive entry not found
> archive:file://home/rbrand/model.zip!/semantic.xmi
> at
> org.eclipse.emf.common.archive.ArchiveURLConnection.getInput Stream(ArchiveURLConnection.java:244)
>
> at
> org.eclipse.emf.ecore.resource.impl.ArchiveURIHandlerImpl.cr eateInputStream(ArchiveURIHandlerImpl.java:59)
>
> at
> org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterIm pl.createInputStream(ExtensibleURIConverterImpl.java:301)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1254)
>
>
>
> Stepping into the resource.save() I could see that the OutputStream is
> closed. But nevertheless it seems not to be written to disk directly.
> Could there be OS caches? Is there a possiblity to flush the Zipfile?
>
>
>]]>Ed Merks2009-09-07T13:16:48-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/617820/#msg_617820
It could well be an OS issue I suppose... I'm just not sure what to do
about it...
Roland Brand wrote:
> Hi Ed
>
> I think the exists() is working properly. When I omit the while-loop
> and call resource.save() only once, I get an IOException when I try to
> read the resource. It really does not exists for a short amount of time.
>
> java.io.IOException: Archive entry not found
> archive:file://home/rbrand/model.zip!/semantic.xmi
> at
> org.eclipse.emf.common.archive.ArchiveURLConnection.getInput Stream(ArchiveURLConnection.java:244)
>
> at
> org.eclipse.emf.ecore.resource.impl.ArchiveURIHandlerImpl.cr eateInputStream(ArchiveURIHandlerImpl.java:59)
>
> at
> org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterIm pl.createInputStream(ExtensibleURIConverterImpl.java:301)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1254)
>
>
>
> Stepping into the resource.save() I could see that the OutputStream is
> closed. But nevertheless it seems not to be written to disk directly.
> Could there be OS caches? Is there a possiblity to flush the Zipfile?
>
>
>]]>Ed Merks2009-09-07T13:16:48-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/484542/#msg_484542
I just filed bug #288799 for this, hoping you can reproduce the problem.]]>Roland Brand2009-09-08T07:53:14-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/618206/#msg_618206
I just filed bug #288799 for this, hoping you can reproduce the problem.]]>Roland Brand2009-09-08T07:53:14-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/484641/#msg_484641
Unfortunately it works fine for me so I can only assume that
network/filesystem issues specific to Linux are at play. I'm not even
in a position to reproduce OS-specific issues nor can I imagine how EMF
itself could address such things.
Roland Brand wrote:
> Hi Ed
>
> I just filed bug #288799 for this, hoping you can reproduce the problem.
>]]>Ed Merks2009-09-08T14:38:07-00:00Re: How to make sure that a resource is written
https://www.eclipse.org/forums/index.php/mv/msg/153631/618207/#msg_618207
Unfortunately it works fine for me so I can only assume that
network/filesystem issues specific to Linux are at play. I'm not even
in a position to reproduce OS-specific issues nor can I imagine how EMF
itself could address such things.
Roland Brand wrote:
> Hi Ed
>
> I just filed bug #288799 for this, hoping you can reproduce the problem.
>]]>Ed Merks2009-09-08T14:38:07-00:00