db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: A question about some synchronized code
Date Fri, 22 Dec 2006 08:37:56 GMT
Raymond Raymond <raymond_derby@hotmail.com> writes:

> Thanks for you answer Knut.
> In org.apache.derby.impl.store.raw.log.LogToFile.java,
> in method checkpointWithTran(), there is a piece of code
> like following:
>
> synchronized (this){
> 	// has someone else found a problem in the raw store?
> 	if (corrupt != null){
> 		throw StandardException.newException(SQLState.LOG_STORE_CORRUPT, corrupt);
>        }
> 	// if another checkpoint is in progress, don't do anything
> 	if (inCheckpoint == true)
> 		proceed = false;
> 	else
> 		inCheckpoint = true;
> 	approxLogLength = endPosition; // current end position
> 	// don't return from inside of a sync block
> }
> if (!proceed){
> 	return false;
> }
>
> see, someone did comment "don't return from inside of a sync block", I
> am not
> sure who wrote the comment. I am just wondering what potential problem it
> will case to return from the inside of a sync block.

Hm, that looks strange... I can't see that there's any problem with
returning from inside that synchronized block. Perhaps it is a
workaround for a JIT bug in an old JVM? I have seen strange pieces of
code other places as well with comments about bugs in certain VMs. It
could also be that the code has changed after the comment was written,
or the comment could have been based on a misunderstanding. But I'm
just guessing.

-- 
Knut Anders

Mime
View raw message