提交 1bbd4cd6 编写于 作者: L lindzh 提交者: dongeforever

[ROCKETMQ-291] Fix System.out.printf throws UnknownFormatConversionException

Author: lindzh <linsony0@163.com>

Closes #168 from lindzh/fix_print.
上级 dc4f3686
...@@ -42,7 +42,7 @@ public class PushConsumer { ...@@ -42,7 +42,7 @@ public class PushConsumer {
@Override @Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) { ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} }
}); });
......
...@@ -44,7 +44,7 @@ public class Consumer { ...@@ -44,7 +44,7 @@ public class Consumer {
@Override @Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) { ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} }
}); });
......
...@@ -45,7 +45,7 @@ public class SqlConsumer { ...@@ -45,7 +45,7 @@ public class SqlConsumer {
@Override @Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) { ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} }
}); });
......
...@@ -41,7 +41,7 @@ public class Consumer { ...@@ -41,7 +41,7 @@ public class Consumer {
@Override @Override
public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) { public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
context.setAutoCommit(false); context.setAutoCommit(false);
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs);
this.consumeTimes.incrementAndGet(); this.consumeTimes.incrementAndGet();
if ((this.consumeTimes.get() % 2) == 0) { if ((this.consumeTimes.get() % 2) == 0) {
return ConsumeOrderlyStatus.SUCCESS; return ConsumeOrderlyStatus.SUCCESS;
......
...@@ -67,7 +67,7 @@ public class Consumer { ...@@ -67,7 +67,7 @@ public class Consumer {
@Override @Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) { ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} }
}); });
......
...@@ -34,7 +34,7 @@ public class PullConsumer { ...@@ -34,7 +34,7 @@ public class PullConsumer {
Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1"); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1");
for (MessageQueue mq : mqs) { for (MessageQueue mq : mqs) {
System.out.printf("Consume from the queue: " + mq + "%n"); System.out.printf("Consume from the queue: %s%n", mq);
SINGLE_MQ: SINGLE_MQ:
while (true) { while (true) {
try { try {
......
...@@ -37,7 +37,7 @@ public class PushConsumer { ...@@ -37,7 +37,7 @@ public class PushConsumer {
@Override @Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) { public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} }
}); });
......
...@@ -26,7 +26,7 @@ public class TransactionCheckListenerImpl implements TransactionCheckListener { ...@@ -26,7 +26,7 @@ public class TransactionCheckListenerImpl implements TransactionCheckListener {
@Override @Override
public LocalTransactionState checkLocalTransactionState(MessageExt msg) { public LocalTransactionState checkLocalTransactionState(MessageExt msg) {
System.out.printf("server checking TrMsg " + msg.toString() + "%n"); System.out.printf("server checking TrMsg %s%n", msg);
int value = transactionIndex.getAndIncrement(); int value = transactionIndex.getAndIncrement();
if ((value % 6) == 0) { if ((value % 6) == 0) {
......
...@@ -92,7 +92,7 @@ public class FiltersrvStartup { ...@@ -92,7 +92,7 @@ public class FiltersrvStartup {
Properties properties = new Properties(); Properties properties = new Properties();
properties.load(in); properties.load(in);
MixAll.properties2Object(properties, filtersrvConfig); MixAll.properties2Object(properties, filtersrvConfig);
System.out.printf("load config properties file OK, " + file + "%n"); System.out.printf("load config properties file OK, %s%n", file);
in.close(); in.close();
String port = properties.getProperty("listenPort"); String port = properties.getProperty("listenPort");
...@@ -116,8 +116,7 @@ public class FiltersrvStartup { ...@@ -116,8 +116,7 @@ public class FiltersrvStartup {
MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig); MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig);
if (null == filtersrvConfig.getRocketmqHome()) { if (null == filtersrvConfig.getRocketmqHome()) {
System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV System.out.printf("Please set the %s variable in your environment to match the location of the RocketMQ installation%n", MixAll.ROCKETMQ_HOME_ENV);
+ " variable in your environment to match the location of the RocketMQ installation%n");
System.exit(-2); System.exit(-2);
} }
......
...@@ -96,7 +96,7 @@ public class NamesrvStartup { ...@@ -96,7 +96,7 @@ public class NamesrvStartup {
MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), namesrvConfig); MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), namesrvConfig);
if (null == namesrvConfig.getRocketmqHome()) { if (null == namesrvConfig.getRocketmqHome()) {
System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV + " variable in your environment to match the location of the RocketMQ installation%n"); System.out.printf("Please set the %s variable in your environment to match the location of the RocketMQ installation%n", MixAll.ROCKETMQ_HOME_ENV);
System.exit(-2); System.exit(-2);
} }
......
...@@ -19,8 +19,10 @@ package org.apache.rocketmq.tools.command; ...@@ -19,8 +19,10 @@ package org.apache.rocketmq.tools.command;
import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.joran.spi.JoranException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options; import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser; import org.apache.commons.cli.PosixParser;
...@@ -102,7 +104,7 @@ public class MQAdminStartup { ...@@ -102,7 +104,7 @@ public class MQAdminStartup {
ServerUtil.printCommandLineHelp("mqadmin " + cmd.commandName(), options); ServerUtil.printCommandLineHelp("mqadmin " + cmd.commandName(), options);
} }
} else { } else {
System.out.printf("The sub command \'" + args[1] + "\' not exist.%n"); System.out.printf("The sub command %s not exist.%n", args[1]);
} }
break; break;
} }
...@@ -128,7 +130,7 @@ public class MQAdminStartup { ...@@ -128,7 +130,7 @@ public class MQAdminStartup {
cmd.execute(commandLine, options, rpcHook); cmd.execute(commandLine, options, rpcHook);
} else { } else {
System.out.printf("The sub command \'" + args[0] + "\' not exist.%n"); System.out.printf("The sub command %s not exist.%n", args[0]);
} }
break; break;
} }
......
...@@ -85,7 +85,7 @@ public class SendMsgStatusCommand implements SubCommand { ...@@ -85,7 +85,7 @@ public class SendMsgStatusCommand implements SubCommand {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
long begin = System.currentTimeMillis(); long begin = System.currentTimeMillis();
SendResult result = producer.send(buildMessage(brokerName, messageSize)); SendResult result = producer.send(buildMessage(brokerName, messageSize));
System.out.printf("rt:" + (System.currentTimeMillis() - begin) + "ms, SendResult=" + result); System.out.printf("rt:" + (System.currentTimeMillis() - begin) + "ms, SendResult=%s", result);
} }
} catch (Exception e) { } catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
......
...@@ -115,7 +115,7 @@ public class ConsumerStatusSubCommand implements SubCommand { ...@@ -115,7 +115,7 @@ public class ConsumerStatusSubCommand implements SubCommand {
String result = String result =
ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue()); ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
if (result.length() > 0) { if (result.length() > 0) {
System.out.printf(result); System.out.printf("%s", result);
} }
} }
} else { } else {
......
...@@ -114,7 +114,7 @@ public class ConsumerSubCommand implements SubCommand { ...@@ -114,7 +114,7 @@ public class ConsumerSubCommand implements SubCommand {
String result = String result =
ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue()); ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
if (result.length() > 0) { if (result.length() > 0) {
System.out.printf(result); System.out.printf("%s", result);
} }
} }
} else { } else {
......
...@@ -50,14 +50,14 @@ public class DecodeMessageIdCommond implements SubCommand { ...@@ -50,14 +50,14 @@ public class DecodeMessageIdCommond implements SubCommand {
String messageId = commandLine.getOptionValue('i').trim(); String messageId = commandLine.getOptionValue('i').trim();
try { try {
System.out.printf("ip=" + MessageClientIDSetter.getIPStrFromID(messageId)); System.out.printf("ip=%s", MessageClientIDSetter.getIPStrFromID(messageId));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
String date = UtilAll.formatDate(MessageClientIDSetter.getNearlyTimeFromID(messageId), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS); String date = UtilAll.formatDate(MessageClientIDSetter.getNearlyTimeFromID(messageId), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
System.out.printf("date=" + date); System.out.printf("date=%s", date);
} catch (Exception e) { } catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
} }
......
...@@ -134,7 +134,7 @@ public class PrintMessageSubCommand implements SubCommand { ...@@ -134,7 +134,7 @@ public class PrintMessageSubCommand implements SubCommand {
maxOffset = consumer.searchOffset(mq, timeValue); maxOffset = consumer.searchOffset(mq, timeValue);
} }
System.out.printf("minOffset=" + minOffset + ", maxOffset=" + maxOffset + ", " + mq); System.out.printf("minOffset=%s, maxOffset=%s, %s", minOffset, maxOffset, mq);
READQ: READQ:
for (long offset = minOffset; offset < maxOffset; ) { for (long offset = minOffset; offset < maxOffset; ) {
...@@ -146,11 +146,11 @@ public class PrintMessageSubCommand implements SubCommand { ...@@ -146,11 +146,11 @@ public class PrintMessageSubCommand implements SubCommand {
printMessage(pullResult.getMsgFoundList(), charsetName, printBody); printMessage(pullResult.getMsgFoundList(), charsetName, printBody);
break; break;
case NO_MATCHED_MSG: case NO_MATCHED_MSG:
System.out.printf(mq + " no matched msg. status=" + pullResult.getPullStatus() + ", offset=" + offset); System.out.printf(mq + " no matched msg. status=%s, offset=%s", pullResult.getPullStatus(), offset);
break; break;
case NO_NEW_MSG: case NO_NEW_MSG:
case OFFSET_ILLEGAL: case OFFSET_ILLEGAL:
System.out.printf(mq + " print msg finished. status=" + pullResult.getPullStatus() + ", offset=" + offset); System.out.printf(mq + " print msg finished. status=%s, offset=%s", pullResult.getPullStatus(), offset);
break READQ; break READQ;
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -279,11 +279,11 @@ public class QueryMsgByIdSubCommand implements SubCommand { ...@@ -279,11 +279,11 @@ public class QueryMsgByIdSubCommand implements SubCommand {
MessageExt msg = defaultMQAdminExt.viewMessage(msgId); MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
if (msg != null) { if (msg != null) {
// resend msg by id // resend msg by id
System.out.printf("prepare resend msg. originalMsgId=" + msgId); System.out.printf("prepare resend msg. originalMsgId=%s", msgId);
SendResult result = defaultMQProducer.send(msg); SendResult result = defaultMQProducer.send(msg);
System.out.printf("%s", result); System.out.printf("%s", result);
} else { } else {
System.out.printf("no message. msgId=" + msgId); System.out.printf("no message. msgId=%s", msgId);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -169,8 +169,7 @@ public class UpdateTopicSubCommand implements SubCommand { ...@@ -169,8 +169,7 @@ public class UpdateTopicSubCommand implements SubCommand {
} }
defaultMQAdminExt.createOrUpdateOrderConf(topicConfig.getTopicName(), defaultMQAdminExt.createOrUpdateOrderConf(topicConfig.getTopicName(),
orderConf.toString(), true); orderConf.toString(), true);
System.out.printf(String.format("set cluster orderConf. isOrder=%s, orderConf=[%s]", System.out.printf("set cluster orderConf. isOrder=%s, orderConf=[%s]", isOrder, orderConf);
isOrder, orderConf.toString()));
} }
System.out.printf("%s", topicConfig); System.out.printf("%s", topicConfig);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册