Thomas Fischer wrote:
Just out of curiosity: Why is it better to iterate over the entries of a
map instead of the keys, if one needs both key and entry ? I know it is
better to use the Entry set if one does not need the key, but here the key
is needed...

In the given loop both parts of the entry are used, see the log.debug() call. The code before took the key from the iterator and used get(key) to read the value. This is basically a search call which is rather expensive. If you need both, key and value, the entryset-iterator provides them without an additional search operation.

If an exception is thrown in a catch block, the finally block is executed,
and an exception is thrown again in the finally block, and the exception is
caught later on, the second exception is caught, and not the first
exception. For example:
[...]

This was just copied from another place where a similar construct was used. See my comment below.

So in my code, I usually close stuff in the try block, set it to null, and
do a not null check in the finally block. If the reference to the resource
is not null, then I know an error has occured, try to close the other stuff
nevertheless, and ignore all exceptions which occur during clean-up (as
there is already an exception in the pipeline). This has the desired
behaviour for both cases. I would suggest that we do the same here. I can
do it, if noone objects.

If everyone agrees, we should also look at the other places where stuff
should be closed again (the connection in doSelect(criteria) and the like).

Feel free. I guess there still are a couple of places where the same things are handled in different ways. To improve code quality, it would be desirable to clean this up, even if it is not strictly an error.

I would not use throwTorqueException() on a Torque exception, but simply
rethrow it.

I thought this was the exact purpose of throwTorqueException(). See the code of this method.

Just for the logs, same as above. What is better in iterating over the
entry set instead of the key set ?
Same as above: performance.

Plus, if the iterator does not iterate over keys but over values, it should
be renamed from keys to values.

"entries" is probably correct. I'll do this.

Bye, ThomasV


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to