提交 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 {
@Override
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;
}
});
......
......@@ -44,7 +44,7 @@ public class Consumer {
@Override
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;
}
});
......
......@@ -45,7 +45,7 @@ public class SqlConsumer {
@Override
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;
}
});
......
......@@ -41,7 +41,7 @@ public class Consumer {
@Override
public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
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();
if ((this.consumeTimes.get() % 2) == 0) {
return ConsumeOrderlyStatus.SUCCESS;
......
......@@ -67,7 +67,7 @@ public class Consumer {
@Override
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;
}
});
......
......@@ -34,7 +34,7 @@ public class PullConsumer {
Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1");
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:
while (true) {
try {
......
......@@ -37,7 +37,7 @@ public class PushConsumer {
@Override
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;
}
});
......
......@@ -26,7 +26,7 @@ public class TransactionCheckListenerImpl implements TransactionCheckListener {
@Override
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();
if ((value % 6) == 0) {
......
......@@ -92,7 +92,7 @@ public class FiltersrvStartup {
Properties properties = new Properties();
properties.load(in);
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();
String port = properties.getProperty("listenPort");
......@@ -116,8 +116,7 @@ public class FiltersrvStartup {
MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig);
if (null == filtersrvConfig.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);
}
......
......@@ -96,7 +96,7 @@ public class NamesrvStartup {
MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), namesrvConfig);
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);
}
......
......@@ -19,8 +19,10 @@ package org.apache.rocketmq.tools.command;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
......@@ -102,7 +104,7 @@ public class MQAdminStartup {
ServerUtil.printCommandLineHelp("mqadmin " + cmd.commandName(), options);
}
} 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;
}
......@@ -128,7 +130,7 @@ public class MQAdminStartup {
cmd.execute(commandLine, options, rpcHook);
} 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;
}
......
......@@ -85,7 +85,7 @@ public class SendMsgStatusCommand implements SubCommand {
for (int i = 0; i < count; i++) {
long begin = System.currentTimeMillis();
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) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
......
......@@ -115,7 +115,7 @@ public class ConsumerStatusSubCommand implements SubCommand {
String result =
ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
if (result.length() > 0) {
System.out.printf(result);
System.out.printf("%s", result);
}
}
} else {
......
......@@ -114,7 +114,7 @@ public class ConsumerSubCommand implements SubCommand {
String result =
ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
if (result.length() > 0) {
System.out.printf(result);
System.out.printf("%s", result);
}
}
} else {
......
......@@ -50,14 +50,14 @@ public class DecodeMessageIdCommond implements SubCommand {
String messageId = commandLine.getOptionValue('i').trim();
try {
System.out.printf("ip=" + MessageClientIDSetter.getIPStrFromID(messageId));
System.out.printf("ip=%s", MessageClientIDSetter.getIPStrFromID(messageId));
} catch (Exception e) {
e.printStackTrace();
}
try {
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) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
}
......
......@@ -134,7 +134,7 @@ public class PrintMessageSubCommand implements SubCommand {
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:
for (long offset = minOffset; offset < maxOffset; ) {
......@@ -146,11 +146,11 @@ public class PrintMessageSubCommand implements SubCommand {
printMessage(pullResult.getMsgFoundList(), charsetName, printBody);
break;
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;
case NO_NEW_MSG:
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;
}
} catch (Exception e) {
......
......@@ -279,11 +279,11 @@ public class QueryMsgByIdSubCommand implements SubCommand {
MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
if (msg != null) {
// 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);
System.out.printf("%s", result);
} else {
System.out.printf("no message. msgId=" + msgId);
System.out.printf("no message. msgId=%s", msgId);
}
} catch (Exception e) {
e.printStackTrace();
......
......@@ -169,8 +169,7 @@ public class UpdateTopicSubCommand implements SubCommand {
}
defaultMQAdminExt.createOrUpdateOrderConf(topicConfig.getTopicName(),
orderConf.toString(), true);
System.out.printf(String.format("set cluster orderConf. isOrder=%s, orderConf=[%s]",
isOrder, orderConf.toString()));
System.out.printf("set cluster orderConf. isOrder=%s, orderConf=[%s]", isOrder, orderConf);
}
System.out.printf("%s", topicConfig);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册