Skip to content

Commit

Permalink
fix LOGBACK-1140
Browse files Browse the repository at this point in the history
  • Loading branch information
ceki committed Feb 25, 2016
1 parent 60952eb commit 5f08289
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
Expand Up @@ -61,6 +61,11 @@ List<Token> tokenize() throws ScanException {
case LITERAL_STATE:
addLiteralToken(tokenList, buf);
break;
case DEFAULT_VAL_STATE:
// trailing colon. see also LOGBACK-1140
buf.append(CoreConstants.COLON_CHAR);
addLiteralToken(tokenList, buf);
break;
case START_STATE:
throw new ScanException("Unexpected end of pattern string");
}
Expand Down
Expand Up @@ -125,6 +125,7 @@ public void colonFollowedByDollar() throws ScanException {
witnessList.add(new Token(Token.Type.LITERAL, "b"));
witnessList.add(Token.CURLY_RIGHT_TOKEN);
assertEquals(witnessList, tokenList);

}

@Test
Expand All @@ -141,4 +142,23 @@ public void defaultSeparatorOutsideVariable() throws ScanException {
assertEquals(witnessList, tokenList);
}

@Test
public void literalContainingColon() throws ScanException {
String input = "a:b";
Tokenizer tokenizer = new Tokenizer(input);
List<Token> tokenList = tokenizer.tokenize();
witnessList.add(new Token(Token.Type.LITERAL, "a"));
witnessList.add(new Token(Token.Type.LITERAL, ":b"));
assertEquals(witnessList, tokenList);
}

@Test
public void literalEndingWithColon_LOGBACK_1140() throws ScanException {
String input = "a:";
Tokenizer tokenizer = new Tokenizer(input);
List<Token> tokenList = tokenizer.tokenize();
witnessList.add(new Token(Token.Type.LITERAL, "a"));
witnessList.add(new Token(Token.Type.LITERAL, ":"));
assertEquals(witnessList, tokenList);
}
}
Expand Up @@ -19,7 +19,6 @@
import java.util.HashMap;
import java.util.Map;

import ch.qos.logback.core.joran.spi.InterpretationContext;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -249,7 +248,15 @@ public void jackrabbit_standalone() {
public void doesNotThrowNullPointerExceptionForEmptyVariable() throws JoranException {
context.putProperty("var", "");
OptionHelper.substVars("${var}", context);

}

@Test
public void trailingColon_LOGBACK_1140() {
String prefix = "c:";
String suffix = "/tmp";
context.putProperty("var", prefix);
String r = OptionHelper.substVars("${var}"+suffix, context);
assertEquals(prefix+suffix, r);
}

}
5 changes: 5 additions & 0 deletions logback-site/src/site/pages/news.html
Expand Up @@ -56,6 +56,11 @@ <h3>2016, Release of version 1.1.6</h3>
addition, <code>RollingFileAppender</code> instances now check for
colliding <span class="option">FileNamePattern</span> values.</p>

<p>Fixed issue with variable substitution with the value ending in
a colon. This problem was reported in <a
href="http://jira.qos.ch/browse/LOGBACK-1140">LOGBACK-1140</a> by
Eric Cook.</p>

<hr width="80%" align="center" />

<h3>February 13th, 2016, Release of version 1.1.5</h3>
Expand Down

0 comments on commit 5f08289

Please sign in to comment.