Okay I'll give it another shot hopefully a bit more clearer..
I'm getting a Room object returned as NULL when it should not a be NULL. The only time it will be NULL is when there is not a room with that recNo. So for example in my database at the moment I have 200 Rooms with ID's from 0 - 199.
I am testing the update function of my server class. I run a while looop 50000 times and in that loop I randomly select a value from 1-100 (Which defenitly exist) as the recNo to update.
Now the problem is that intermitently and sometimes this will not happen a NULL is returned even though that recNo exists! For example it might happen at 23,456 or 996 and sometimes it may not happen at all.
At the moment I am just running ONE thread to isolate the problem..
To make this go away I have to uncomment the code in the first method, so basically I call getFromFile twice and it works!!! I don't know why and to me this is an unacceptable soultion.
I have tried Synchronizing but it still happens, has anybody had this before.?
Joined: Jul 17, 2006
If I un comment the bolded code then it works always!!!
Hello Jason, since you are "testing" and using a list collection ... how are you populating the list? Ideally if the data record is deleted or doesn't exist, you don't need to add it to the list. When you get the room object, are you doing it randomly like this:
If you do this, yes the room object may be null. So you do need to check if room is null before updating.
Also I noticed you are using long, if the Sun's provided interface use int for record number, there is no need to promote to long. If you are testing, shouldn't the list be shared? Why do you have it as local variable inside getRoomObject() method?
You may want to check out this thread for testing your Data class for URLyBird.
For most people the server classes and Data class locking are the hardest because not everyone exposes to manually locking and RMI before they do SCJD (assuming you don't do this kind of stuff at work).
So if you solve your current situation, you are 1/4 way throught.
Jason Marshall wrote:
Is the server classes the hardest part of this assignment or is there more curlers to come?
I will give a quick view how i experienced this assignment. Remark: I'm doing this assignment together with a full-time job and a social life, so I've only time to develop in the evenings and the weekends.
I started January 2009 with the SCJD-assignment and started with the Data-class (implementing sun's interface) and i made my own test providing 100% test coverage: a test-case for each possible situation (normal run of method, exceptions that could be thrown,...). Then i used Roberto Perillo's test-case to make sure my locking mechanism won't result in a deadlock. Each time when i made a change to Data I ran those tests again, to make sure changes don't have any effect on the program. Duration: 6 weeks.
I chose to use a seperate business layer, so i made my local implementation (+ full coverage test) and my RMI implementation (+ full coverage test + a test to see if my booking process is flawless). At the end of March i finished it (was 2 weeks unable to code due to illness).
And if everything goes as expected, this weekend i should complete my GUI and thus i should finish the coding part (and i did not spend more time each day on it then in the first 3 months).
So implementing sun's interface is the most important thing + making sure your code doesn't deadlock, so i spend most of my time doing that because if your code deadlocks you may receive 0/80 for locking and so it's almost impossible to pass. During development i used a wip-package and if my class was finished i javadoc'ed it completely and moved it to the appropriate package. So a finished class is really finished and i don't have to spend extra time to javadoc afterwards.
So you could easily say server class are the hardest and most important of the whole assignment. marking confirms this: 160 points on server, just 40 on gui, 70 on javadoc and 130 on general consideration + object oriented)
Thanks very much for your time to explain to me how your assignment is going. I am the same as you and probably most of us here trying to develop whilst working full time jobs and trying to enjoy life as well.
Can I ask a few questions to you, I have run Roberto Perillo's test-case class and I find I do not ever get a deadlock, but if I increase the loop to about 1000+ I start getting JVM Thread out of memory exceptions, is this to be encountered? Also what does wip-package mean.
Once again thanks for your detailed explanation earlier.
Jason Marshall wrote:Can I ask a few questions to you
Yes, you can.
Jason Marshall wrote:
I have run Roberto Perillo's test-case class and I find I do not ever get a deadlock, but if I increase the loop to about 1000+ I start getting JVM Thread out of memory exceptions, is this to be encountered?
I ran Roberto's test-case with a counter of 20000 and i never got an OutOfMemory-exception. So i'm afraid you have some kind of memory-leak. It certainly is weird to have such an exception. i guess you are the 1st person to report such a problem
Jason Marshall wrote:
Also what does wip-package mean.
You know Jason, I also ran into OutOfMemoryExceptions, when I (just for curiosity) tested my Data class in standalone and networked mode at the same time (and for the networked mode, I created other test cases) and increased the loop's controller variable to about 100000000 (just for curiosity because this isn't really necessary). But we can consider 1000 a low number in this context. However, I don't know how they test our locking strategy (for instance, their controller variable can be 10 or 10000000!), so I don't really know if we got a problem here, but maybe you can consider reviewing your Data class/locking strategy to make sure you are not using more resources than needed, just for the sake of security.