Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IO Exception while checking for deleted record

 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In my update record method I am checking whether the given record number is marked deleted or not
(The method signature is
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException)

My question is
1. Assume that the record number given to update was actually a deleted one
2. The try block generated a IOException while doing some raf.seek or raf.read
3. Flow comes after the catch block and checks the delete flag, but it was not set to 1 as it was not read. Hence RecordnotFoundexception was not thrown.
4. But remaining portions of update method work and somehow access to file is gained and deleted record gets updated, which we dont want to happen.

How are you all dealing with this scenario in your method.


[ April 16, 2008: Message edited by: Mary John ]
[ April 16, 2008: Message edited by: Mary John ]
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Mary,

you could rethrow the IOException, or wrap it in another Exception (probably a RuntimeException) and throw that one.

Herman
 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, got it now. Just found out similar issues being discussed in the forum before..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic