ARTEMIS-1395 Clean up toString code

Clean up toString code and properly log error message.
This commit is contained in:
Timothy Bish 2017-09-08 12:44:07 -04:00
parent 9c31055aba
commit 8dddc7370c
1 changed files with 3 additions and 10 deletions

View File

@ -22,7 +22,6 @@ import java.nio.ByteBuffer;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Set; import java.util.Set;
import io.netty.buffer.ByteBuf;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQException;
@ -43,6 +42,8 @@ import org.apache.activemq.artemis.utils.UUID;
import org.apache.activemq.artemis.utils.collections.TypedProperties; import org.apache.activemq.artemis.utils.collections.TypedProperties;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import io.netty.buffer.ByteBuf;
/** Note: you shouldn't change properties using multi-threads. Change your properties before you can send it to multiple /** Note: you shouldn't change properties using multi-threads. Change your properties before you can send it to multiple
* consumers */ * consumers */
public class CoreMessage extends RefCountMessage implements ICoreMessage { public class CoreMessage extends RefCountMessage implements ICoreMessage {
@ -1066,7 +1067,6 @@ public class CoreMessage extends RefCountMessage implements ICoreMessage {
initBuffer(size); initBuffer(size);
buffer.setIndex(0, 0).writeBytes(record.byteBuf(), size); buffer.setIndex(0, 0).writeBytes(record.byteBuf(), size);
decode(); decode();
} }
@Override @Override
@ -1074,8 +1074,6 @@ public class CoreMessage extends RefCountMessage implements ICoreMessage {
return this; return this;
} }
@Override @Override
public String toString() { public String toString() {
try { try {
@ -1084,21 +1082,16 @@ public class CoreMessage extends RefCountMessage implements ICoreMessage {
", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) + ", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) +
", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties + "]@" + System.identityHashCode(this); ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties + "]@" + System.identityHashCode(this);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); logger.warn("Error creating String for message: ", e);
System.exit(-1);
return "ServerMessage[messageID=" + messageID + "]"; return "ServerMessage[messageID=" + messageID + "]";
} }
} }
private static String toDate(long timestamp) { private static String toDate(long timestamp) {
if (timestamp == 0) { if (timestamp == 0) {
return "0"; return "0";
} else { } else {
return new java.util.Date(timestamp).toString(); return new java.util.Date(timestamp).toString();
} }
} }
} }