activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaelandrepearce <...@git.apache.org>
Subject [GitHub] activemq-artemis pull request #2427: ARTEMIS-2170 Optimized CoreMessage's ch...
Date Wed, 14 Nov 2018 16:10:54 GMT
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/2427#discussion_r233513078
  
    --- Diff: artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
---
    @@ -564,34 +604,59 @@ public CoreMessage setUserID(UUID userID) {
        /**
         * I am keeping this synchronized as the decode of the Properties is lazy
         */
    -   protected TypedProperties checkProperties() {
    +   protected final TypedProperties checkProperties() {
           try {
    +         TypedProperties properties = this.properties;
              if (properties == null) {
    -            synchronized (this) {
    -               if (properties == null) {
    -                  TypedProperties properties = new TypedProperties();
    -                  if (buffer != null && propertiesLocation >= 0) {
    -                     final ByteBuf byteBuf = buffer.duplicate().readerIndex(propertiesLocation);
    -                     properties.decode(byteBuf, coreMessageObjectPools == null ? null
: coreMessageObjectPools.getPropertiesDecoderPools());
    -                  }
    -                  this.properties = properties;
    -               }
    +            properties = getOrInitializeTypedProperties();
    +         }
    +         return properties;
    +      } catch (Throwable e) {
    +         throw onCheckPropertiesError(e);
    +      }
    +   }
    +
    +   private TypedProperties getOrInitializeTypedProperties() {
    +      synchronized (this) {
    +         TypedProperties properties = this.properties;
    +         if (properties == null) {
    +            properties = createTypedProperties();
    +            if (buffer != null && propertiesLocation >= 0) {
    +               final ByteBuf byteBuf = buffer.duplicate().readerIndex(propertiesLocation);
    +               properties.decode(byteBuf, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools());
                 }
    +            this.properties = properties;
              }
    +         return properties;
    +      }
    +   }
     
    -         return this.properties;
    -      } catch (Throwable e) {
    -         ByteBuf duplicatebuffer = buffer.duplicate();
    -         duplicatebuffer.readerIndex(0);
    +   private RuntimeException onCheckPropertiesError(Throwable e) {
    +      ByteBuf duplicatebuffer = buffer.duplicate();
    +      duplicatebuffer.readerIndex(0);
     
    -         // This is not an expected error, hence no specific logger created
    -         logger.warn("Could not decode properties for CoreMessage[messageID=" + messageID
+ ",durable=" + durable + ",userID=" + userID + ",priority=" + priority +
    -            ", timestamp=" + timestamp + ",expiration=" + expiration + ",address=" +
address + ", propertiesLocation=" + propertiesLocation, e);
    -         logger.warn("Failed message has messageID=" + messageID + " and the following
buffer:\n" + ByteBufUtil.prettyHexDump(duplicatebuffer));
    +      // This is not an expected error, hence no specific logger created
    +      logger.warn("Could not decode properties for CoreMessage[messageID=" + messageID
+ ",durable=" + durable + ",userID=" + userID + ",priority=" + priority +
    +                     ", timestamp=" + timestamp + ",expiration=" + expiration + ",address="
+ address + ", propertiesLocation=" + propertiesLocation, e);
    +      logger.warn("Failed message has messageID=" + messageID + " and the following buffer:\n"
+ ByteBufUtil.prettyHexDump(duplicatebuffer));
     
    -         throw new RuntimeException(e.getMessage(), e);
    +      return new RuntimeException(e.getMessage(), e);
    --- End diff --
    
    This really should throw the original exception, dont wrap it into something else, incase
other code was catching something explicit.


---

Mime
View raw message