Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RemoteException and IOException

 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currenlty my lock method inside Data access Interface throws both java.rmi.RemoteException and java.io.IOException exceptions. And unlock does not throw IOException. Should unlock also throw both java.rmi.RemoteException and IOException. Or if these methods just throw IOExcpetion then it is fine.
Also does the data close method has to throw a IOException?
And does all the methods inside the Data access Interface has to throw DatabaseException, because not all methods inside Data class throws DatabaseException example getFieldInfo().
Thanks.
[ September 10, 2002: Message edited by: Samual Harvey ]
[ September 10, 2002: Message edited by: Samual Harvey ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Samual,

Currenlty my lock method inside Data throws both java.rmi.RemoteException and java.io.IOException exceptions.

Actually you don't even have to throw RemoteException from lock() since RemoteException is an IOException.

... And unlock does not throw IOException. Should unlock also throw both java.rmi.RemoteException and IOException.

Nope. Just throw RemoteException in unlock(). unlock() simply ignores invalid requests by the requirements, so there is no need to throw IOException.

Also does the data close method has to throw a IOException?

Nope. The designer of Data has gone out of his way to ignore the possible IOException thrown by RandomAccessFile's close() method.
Hope this helps,
Michael Morris
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
How about this:-
And does all the methods inside the Data access Interface has to throw DatabaseException, because not all methods inside Data class throws DatabaseException example getFieldInfo().

Thanks.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Samual,
Nope. Just leave it like it is. Data has been designed to throw a DatabaseException whenever the RandomAccessFile cannot be accessed or when attempting to create or delete an invalid record.
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic