[hornetq-commits] JBoss hornetq SVN: r11335 - in branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp: v10 and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Sep 13 00:21:17 EDT 2011


Author: gaohoward
Date: 2011-09-13 00:21:16 -0400 (Tue, 13 Sep 2011)
New Revision: 11335

Modified:
   branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/HornetQStompException.java
   branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompConnection.java
   branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompProtocolManager.java
   branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/v10/StompFrameHandlerV10.java
Log:
fix tests


Modified: branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/HornetQStompException.java
===================================================================
--- branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/HornetQStompException.java	2011-09-13 01:17:00 UTC (rev 11334)
+++ branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/HornetQStompException.java	2011-09-13 04:21:16 UTC (rev 11335)
@@ -12,6 +12,7 @@
  */
 package org.hornetq.core.protocol.stomp;
 
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -25,7 +26,13 @@
    
    private List<Header> headers = new ArrayList<Header>(10);
    private String body;
+   private VersionedStompFrameHandler handler;
    
+   public HornetQStompException(StompConnection connection, String msg)
+   {
+      super(msg);
+      handler = connection.getFrameHandler();
+   }
    public HornetQStompException(String msg)
    {
       super(msg);
@@ -53,7 +60,32 @@
 
    public StompFrame getFrame()
    {
-      return null;
+      StompFrame frame = null;
+      if (handler == null)
+      {
+         frame = new StompFrame("ERROR");
+         frame.addHeader("message", this.getMessage());
+         if (body != null)
+         {
+            try
+            {
+               frame.setByteBody(body.getBytes("UTF-8"));
+            }
+            catch (UnsupportedEncodingException e)
+            {
+            }
+         }
+         else
+         {
+            frame.setByteBody(new byte[0]);
+         }
+      }
+      else
+      {
+         frame = handler.createStompFrame("ERROR");
+         frame.addHeader("message", this.getMessage());
+      }
+      return frame;
    }
 
    private class Header

Modified: branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompConnection.java
===================================================================
--- branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompConnection.java	2011-09-13 01:17:00 UTC (rev 11334)
+++ branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompConnection.java	2011-09-13 04:21:16 UTC (rev 11335)
@@ -559,10 +559,6 @@
       {
          manager.commitTransaction(this, txID);
       }
-      catch (HornetQStompException e)
-      {
-         throw e;
-      }
       catch (Exception e)
       {
          throw new HornetQStompException("Error committing " + txID, e);

Modified: branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompProtocolManager.java
===================================================================
--- branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompProtocolManager.java	2011-09-13 01:17:00 UTC (rev 11334)
+++ branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompProtocolManager.java	2011-09-13 04:21:16 UTC (rev 11335)
@@ -386,9 +386,11 @@
 
    public void beginTransaction(StompConnection connection, String txID) throws Exception
    {
+      log.error("-------------------------------begin tx: " + txID);
       if (transactedSessions.containsKey(txID))
       {
-         throw new HornetQStompException("Transaction already started: " + txID);
+         log.error("------------------------------Error, tx already exist!");
+         throw new HornetQStompException(connection, "Transaction already started: " + txID);
       }
       // create the transacted session
       getTransactedSession(connection, txID);

Modified: branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/v10/StompFrameHandlerV10.java
===================================================================
--- branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/v10/StompFrameHandlerV10.java	2011-09-13 01:17:00 UTC (rev 11334)
+++ branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/v10/StompFrameHandlerV10.java	2011-09-13 04:21:16 UTC (rev 11335)
@@ -336,13 +336,16 @@
       int size = bodyPos - buffer.readerIndex();
       buffer.readerIndex(MessageImpl.BUFFER_HEADER_SPACE + DataConstants.SIZE_INT);
       byte[] data = new byte[size];
+      
       if (serverMessage.containsProperty(Stomp.Headers.CONTENT_LENGTH) || serverMessage.getType() == Message.BYTES_TYPE)
       {
+         log.error("------------------- server message is  byte");
          frame.addHeader(Headers.CONTENT_LENGTH, String.valueOf(data.length));
          buffer.readBytes(data);
       }
       else
       {
+         log.error("------------------- server message is  text");
          SimpleString text = buffer.readNullableSimpleString();
          if (text != null)
          {
@@ -353,6 +356,8 @@
             data = new byte[0];
          }
       }
+      frame.setByteBody(data);
+
       serverMessage.getBodyBuffer().resetReaderIndex();
 
       StompUtils.copyStandardHeadersFromMessageToFrame(serverMessage, frame, deliveryCount);



More information about the hornetq-commits mailing list