ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Best Practices for Exception Handling
Subject:   "Alternatively, you can even provide a method that checks if the username is already taken." not working
Date:   2003-11-24 00:31:32
From:   anonymous2
"Alternatively, you can even provide a method that checks if the username is already taken."
does not work!


for example, I have a
register(User) method, who's singnature is like


public register(User) throws DuplicateUsernameException


if I provide a method that checks if the username is already taken. does that mean , I can change the singnature like
public register(User);
// remove the throws DuplicateUsernameException
that is totally wrong, because the author ignore the multi-client case, that is ,
thread 1: checkUserNameExist("myname"); //true
thread 2: checkUserNameExist("myname"); //true
thread 1: register("myname"); //success
thread 2: register("myname"); //should fail, but the caller does not know.





1 to 1 of 1
  1. "Alternatively, you can even provide a method that checks if the username is already taken." not working
    2003-12-03 14:07:00  anonymous2 [View]

1 to 1 of 1