OutOfMemoryError is not a RuntimeException but an Error, isn't it?

The debug was from that code but I think the exception was really a
RuntimeException and not an OutOfMemoryError: it probably was encapsulated
in a RuntimeException before.

Let's read the DEBUG log...

> DEBUG mailstore: Exception retrieving mail:
> java.lang.RuntimeException: Exception caught while retrieving an 
> object, cause: java.lang.OutOfMemoryError, so we're deleting it... 
> good riddance!

So the "re" caught is a Runtime and is created by the
File_Persistent_Object_Repository with this snippet:

catch( final Throwable e )
{
    throw new RuntimeException(
    "Exception caught while retrieving an object, cause: " + e.toString() );
} 

I think this patch is wrong (the OOME is not a RuntimeException!). You
should change the File_Persistent_Object_Repository.

Stefano

> james/server/trunk/src/java/org/apache/james/mailrepository/AvalonMa
> +++ ilRepository.java Wed Jun 22 03:36:11 2005
> @@ -333,12 +333,20 @@
>              MailImpl mc = null;
>              try {
>                  mc = (MailImpl) or.get(key);
> -            } catch (RuntimeException re) {
> +            } catch(OutOfMemoryError oome){
> +                StringBuffer exceptionBuffer =
> +                    new StringBuffer(128)
> +                            .append("Exception retrieving mail: ")
> +                            .append(oome.toString());
> +                getLogger().debug(exceptionBuffer.toString());
> +                return null;
> +            }
> +            catch (RuntimeException re) {
>                  StringBuffer exceptionBuffer =
>                      new StringBuffer(128)
>                              .append("Exception retrieving mail: ")
>                              .append(re.toString())
> -                            .append(", so we're deleting 
> it... good riddance!");
> +                            .append(", so we're deleting it.");
>                  getLogger().debug(exceptionBuffer.toString());
>                  remove(key);
>                  return null;


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

Reply via email to