I received my
SCJD score this week (passed with a score of 354/400):
General Considerations (maximum = 100): 99
Documentation (maximum = 70): 70
O-O Design (maximum = 30): 30
GUI (maximum = 40): 31
Locking (maximum = 80): 44
Data store (maximum = 40): 40
Network server (maximum = 40): 40
I am somewhat disappointed because I don't think I missed anything with my locking approach. Can someone help me find out? Is it possible the assessor made a mistake?
Here is how I implemented locking on the client side:
a) lock the record and get a lock cookie
c) read the record and ensure it is not booked
d) book the record using the lock cookie
e) unlock the record using the lock cookie
Server has a class that manages record locks using a HashMap<Long, Long> such that only one client can have a lock to a record at any given time.
lock (record number):
a) wait if the record is already locked
b) generate a random number for the lock cookie
c) add to the hash map with record number and lock cookie
d) return the lock cookie
unlock (record number, lock cookie):
a) check if the record is currently locked. if not, return
b) verify that the lock cookie matches the cookie in the hash map for this record. if not, throw a security exception
c) remove the record number entry from the hash map
d) notify others waiting on this record
I would appreciate any pointers you can provide. Thank you.