Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#110946 - 14/08/2002 20:09 one line that causes so much trouble
mschrag
pooh-bah

Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
[rant]
It's amazing how many problems a single wrong line of code can cause... All the problems people are having with jEmplode and playlists not being all removed properly is a single line of code that accidentally modified a list while something else was enumerating it ... In the spirit of useless code, Java decided it was best to stay silent there and just let me stumble through hours of annoying debugging rather than just throw an exception and let me know that i've done a bad thing. It's amazing that in the year 2002 the same braindead problems go undetected.

Oh well.
[/rant]

Mike

Top
#110947 - 14/08/2002 21:06 Re: one line that causes so much trouble [Re: mschrag]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
emplode.protocol.do_the_wrong_thing(), huh?
_________________________
Bitt Faulk

Top
#110948 - 16/08/2002 06:12 Re: one line that causes so much trouble [Re: mschrag]
anti
member

Registered: 10/07/2000
Posts: 117
Loc: BaWue, Germany, Europe
Don't tell me you hit the "old" ArrayList problem ?
<quote>
java.util
Class ArrayList:
Note that this implementation is not synchronized.
...
...the list should be "wrapped" using the Collections.synchronizedList method.
</quote>

You are not the first one to hit this problem.
And I think you won't be the last.

Good that you found it !


Edited by anti (16/08/2002 06:12)
_________________________
-------------------- MKII 08000073 40GB BLUE

Top
#110949 - 16/08/2002 06:17 Re: one line that causes so much trouble [Re: anti]
mschrag
pooh-bah

Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
Oh no .. this is even more sinister than normal synchronization... And actually, I think ArrayList may not suffer from this problem I ran into, but I am forced to use Vector to maintain 1.1 compatibility.

Basically, make a call to .elements() and start going through the Enumeration. While enumerating the elements, modify the Vector. It silently works and just screws the Enumeration all up (i.e. off-by-one's, etc). I _think_ that ArrayList (and the new collections) throw a ConcurrentModificationException.... But not our old retarded friend Vector.

The actual deal was that while enumerating dirty nodes during synchronization, I clean up after synching each node. Well, the cleanup for an FIDDeleted is to actually complete the deletion and remove it from memory. This was pretty indirect, but what it meant was that ultimately I was changing the Vector of nodes that I was in the middle of enumerating. I changed the implementation instead to just mark it setDirty(false) and just leave it in memory. If the sync succeeds, it will just reload the database anyway, so this code is really only there to handle cancelling in the middle of a sync.

Bleaugh.

ms

Top