[jboss-cvs] jboss-jms/src/main/org/jboss/jms/util ...

Timothy Fox tim.fox at jboss.com
Thu Jul 27 15:01:55 EDT 2006


  User: timfox  
  Date: 06/07/27 15:01:55

  Modified:    src/main/org/jboss/jms/util   
                        MessagingTransactionRolledBackException.java
                        SafeUTF.java
  Added:       src/main/org/jboss/jms/util    ExceptionUtil.java
  Log:
  Mainly http://jira.jboss.com/jira/browse/JBMESSAGING-434 plus a few other bits and pieces
  
  Revision  Changes    Path
  1.2       +2 -3      jboss-jms/src/main/org/jboss/jms/util/MessagingTransactionRolledBackException.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MessagingTransactionRolledBackException.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-jms/src/main/org/jboss/jms/util/MessagingTransactionRolledBackException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- MessagingTransactionRolledBackException.java	28 Mar 2006 14:26:17 -0000	1.1
  +++ MessagingTransactionRolledBackException.java	27 Jul 2006 19:01:55 -0000	1.2
  @@ -23,7 +23,6 @@
   
   import javax.jms.TransactionRolledBackException;
   
  -import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
   import org.jboss.logging.Logger;
   
   /**
  
  
  
  1.3       +2 -3      jboss-jms/src/main/org/jboss/jms/util/SafeUTF.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SafeUTF.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-jms/src/main/org/jboss/jms/util/SafeUTF.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- SafeUTF.java	17 Jul 2006 17:14:47 -0000	1.2
  +++ SafeUTF.java	27 Jul 2006 19:01:55 -0000	1.3
  @@ -26,7 +26,6 @@
   import java.io.ObjectOutput;
   
   import org.jboss.logging.Logger;
  -import org.jboss.messaging.core.message.MessageSupport;
   
   /**
    * 
  @@ -34,9 +33,9 @@
    * 
    * @author <a href="tim.fox at jboss.com">Tim Fox</a>
    * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    *
  - * $Id: SafeUTF.java,v 1.2 2006/07/17 17:14:47 timfox Exp $
  + * $Id: SafeUTF.java,v 1.3 2006/07/27 19:01:55 timfox Exp $
    * 
    * There is a "bug" in JDK1.4 / 1.5 DataOutputStream.writeUTF()
    * which means it does not work with Strings >= 64K serialized size.
  
  
  
  1.1      date: 2006/07/27 19:01:55;  author: timfox;  state: Exp;jboss-jms/src/main/org/jboss/jms/util/ExceptionUtil.java
  
  Index: ExceptionUtil.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  package org.jboss.jms.util;
  
  import javax.jms.JMSException;
  
  import org.jboss.logging.Logger;
  
  /**
   * A ExceptionUtil
  
   * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
   * @version <tt>$Revision: 1.1 $</tt>
   *
   * $Id: ExceptionUtil.java,v 1.1 2006/07/27 19:01:55 timfox Exp $
   *
   */
  public class ExceptionUtil
  {
     private static final Logger log = Logger.getLogger(ExceptionUtil.class);
     
     /*
      * The strategy for what how we propagate Throwables from the server to the client
      * in the event of one occuring on the server in a client initiated invocation is as
      * follows:
      * 1) We always log the Throwable irrespective of it's type - this is so system administrators
      * have a record of what has happened - typically they may configure log4j to send an email
      * or create some other alert when this happens
      * 2) If the exception is a JMSException that was created and thrown in the messaging code, then
      * this is propagated back to the client
      * 4) Any other Errors or Exceptions (e.g. SQLException) are rethrown as a JMSException
      * - we do not want to propagate the original exception back to the client since the client may not
      * have the correct jars to receive the exception - (e.g. if it was an exception thrown from a postgressql driver)
      * Also there maybe security reasons we do not want to expose the specific original exception to the client
      */
     public static JMSException handleJMSInvocation(Throwable t, String msg)
     {
        //First we log the Throwable
        log.error(msg, t);
        
        if (t instanceof JMSException)
        {
           return (JMSException)t;
        }
        else
        {
           JMSException e = new MessagingJMSException("A failure has occurred during processing of the request. " + 
                                                      "Please consult the server logs for more details. " + msg);    
           return e;
        }    
     }   
     
     /*
      * This method is used to log any Throwables occurring in the execution of JMX methods before
      * propagating them back to the caller.
      * If we don't log them then we have no record of them occurring on the server.
      */
     public static Exception handleJMXInvocation(Throwable t, String msg)
     {
        log.error(msg, t);
        
        if (t instanceof RuntimeException)
        {
           throw (RuntimeException)t;
        }
        else if (t instanceof Error)
        {
           throw (Error)t;
        }
        else if (t instanceof Exception)
        {
           //Some other non RuntimeException
           return (Exception)t;
        }
        else
        {
           //Some other subclass of Throwable
           throw new RuntimeException(msg);
        }         
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list