Skip to content

Commit

Permalink
fix trie match bug when topic contains root, with test case;
Browse files Browse the repository at this point in the history
fix bytesMetrics wroteBytes always 0;
fix startup shell can not run outside bin;
  • Loading branch information
ilylia committed Jun 20, 2019
1 parent d2cce3f commit 74d92f9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
BytesMetrics metrics = ctx.channel().attr(ATTR_KEY_METRICS).get();
metrics.incrementWrote(((ByteBuf) msg).writableBytes());
metrics.incrementWrote(((ByteBuf) msg).readableBytes());
ctx.write(msg, promise).addListener(CLOSE_ON_FAILURE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IVisitor<T> {
T getResult();
}

private static final Token ROOT = new Token("root");
private static final Token ROOT = new Token("+root");
private static final INode NO_PARENT = null;

private enum Action {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public void testMatchSimple() {

assertThat(sut.matchWithoutQosSharpening(asTopic("/finance"))).contains(slashFinanceSub);
assertThat(sut.matchWithoutQosSharpening(asTopic("/"))).contains(slashSub);

Subscription rootSub = clientSubOnTopic("TempSensor1", "root");
sut.add(rootSub);
assertThat(sut.matchWithoutQosSharpening(asTopic("root"))).contains(rootSub);
}

@Test
Expand All @@ -67,6 +71,10 @@ public void testMatchSimpleMulti() {
Subscription financeAnySub = clientSubOnTopic("TempSensor1", "finance/#");
sut.add(financeAnySub);
assertThat(sut.matchWithoutQosSharpening(asTopic("finance"))).containsExactlyInAnyOrder(financeAnySub, anySub);

Subscription rootSub = clientSubOnTopic("TempSensor1", "root/#");
sut.add(rootSub);
assertThat(sut.matchWithoutQosSharpening(asTopic("root/test"))).contains(rootSub);
}

@Test
Expand Down Expand Up @@ -168,6 +176,11 @@ public void rogerLightTopicMatches() {
assertMatch("foo//+", "foo//bar");
assertMatch("foo/+/+/baz", "foo///baz");
assertMatch("foo/bar/+", "foo/bar/");

assertMatch("root//bar", "root//bar");
assertMatch("root//+", "root//bar");
assertMatch("foo/+/+/root", "foo///root");
assertMatch("foo/root/+", "foo/root/");
}

private void assertMatch(String s, String t) {
Expand Down
6 changes: 2 additions & 4 deletions distribution/src/main/scripts/moquette.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ echo " \_| |_/\___/ \__, |\__,_|\___|\__|\__\___| \_| |_/\_/\_\ \_/ \_/ "
echo " | | "
echo " |_| "
echo " "
echo " version: 0..13-SNAPSHOT "
echo " version: 0.13-SNAPSHOT "


cd "$(dirname "$0")"

# resolve links - $0 may be a softlink
PRG="$0"

Expand All @@ -39,7 +37,7 @@ PRGDIR=`dirname "$PRG"`
export MOQUETTE_HOME

# Set JavaHome if it exists
if [ -f "${JAVA_HOME}/bin/java" ]; then
if [ -f "${JAVA_HOME}/bin/java" ]; then
JAVA=${JAVA_HOME}/bin/java
else
JAVA=java
Expand Down

0 comments on commit 74d92f9

Please sign in to comment.