On 9/1/06, Andrew Zhang wrote:

On 9/1/06, Stepan Mishura  wrote:
<SNIP>
OK, I'll try to put the
> question in other words: if there is 2 VM running on the same machine
and
> on
> both VMs new FileHandler() is invoked then there is a files conflict.
And
> it
> is possible to resolve such kind of conflict only by creating lock-file.


RI output:
a a.1 a.lck a.1.lck

Harmony output
a a.1

The test case is simple if you'd like to try, just run two times, and
check
the log file in your disk.
public void test_FileHandler() throws Exception {
       FileHandler handler = new FileHandler("a");
       handler.publish(new LogRecord(Level.SEVERE, "msg"));
       int count = 0;
       while (count++ < 60) {
           Thread.sleep(1000);
       }
       handler.close();
   }


Andrew, thanks for the test. But working test doesn't mean that there is no
bug :-)

AFAIK in our case an operation on file (if file is not exist  - create file)
should be atomic. And it looks like Harmony implementation doesn't do in
atomic way.(see FileHandler.initOutputFiles() method)

Thanks,
Stepan.


> Thanks,
> Stepan.
>
>
> >
> >
> > > >
> > > > > RI tries to delete the created file if FileHandler.close() is
> > > invoked.
> > > > And
> > > > > > Harmony doesn't. Why?
> > > > > >
> > > > > > Thanks,
> > > > > > Stepan.
> > > > > >
> > > > > > If we revise the MockSecurityManager a little, to allow .lck
> file
> > > > > > > permission,
> > > > > > >
> > > > > > >    public void checkPermission(Permission perm) {
> > > > > > >            if (perm instanceof FilePermission) {
> > > > > > >                if (perm.getName().indexOf(".lck") == -1) {
> > > > > > >                    System.out.println("check " +
perm.getName
> > > ());
> > > > > > >                    throw new SecurityException();
> > > > > > >                }
> > > > > > >            }
> > > > > > >        }
> > > > > > >
> > > > > > > The test will pass both against RI and Harmony.
> > > > > > >
> > > > > > > So I'd suggest to leave it as "non-bug difference from RI".
> > > > > > >
> > > > > > > Any comments? Thank you!
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Andrew Zhang
> > > > > > > China Software Development Lab, IBM


------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to