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

UrlYBird - DuplicateKeyException in the create method ?

 
Marcio Aun Migueis
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

I was trying to create a few records for test, and I don�t understand this exception in the create method:



I put the syncrhonized keyword in the signature and I don�t understand how could be possible to catch a DuplicateKeyException. What it�s the key ? The record number ?

If the method is synchronized, only one client can create a record at a given time. Correct ? Do I have to lock the record before write it in the file ? Locking a new record that doesn�t exist?

Please, help me!

Thanks a lot in advance,

M�rcio

(from Brazil)
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi M�rcio,

Just because a method signature declares that a particular exception might be thrown does not mean that you have to throw it. If you cannot find a unique key in the data you have been provided (and from memory you cannot get a unique key in URLyBird) then you may want to just consider it as something intended for future use.

Regards, Andrew
 
Arno Hola
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marcio Aun Migueis:
Hi !

I was trying to create a few records for test, and I don�t understand this exception in the create method:



I put the syncrhonized keyword in the signature and I don�t understand how could be possible to catch a DuplicateKeyException. What it�s the key ? The record number ?

If the method is synchronized, only one client can create a record at a given time. Correct ? Do I have to lock the record before write it in the file ? Locking a new record that doesn�t exist?

Please, help me!

Thanks a lot in advance,

M�rcio

(from Brazil)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic