-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from pxcurtis/bugfix/issue64
Bugfix for issue #64; purge closed loggers from factory cache
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.fluentd.logger; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Collections; | ||
|
||
import org.junit.Test; | ||
|
||
public class TestBugfixes { | ||
/** Prior to the issue fix, this test fails with an NPE on the last line. | ||
*/ | ||
@Test | ||
public void validLoggerReturned_whenOpenThenCloseThenOpenWithSameParameters() { | ||
// use test sender so we don't need to have an actual fluentd running... | ||
System.setProperty(Config.FLUENT_SENDER_CLASS, "org.fluentd.logger.sender.NullSender"); | ||
FluentLogger logger = FluentLogger.getLogger("test"); | ||
|
||
// this works | ||
logger.log("tag", Collections.<String, Object>emptyMap()); | ||
|
||
// now close it; sender is closed and set to null | ||
logger.close(); | ||
assertEquals(null, logger.sender); | ||
|
||
// get another logger with the exact same parameters; we'd expect this to work, yes? | ||
FluentLogger logger2 = FluentLogger.getLogger("test"); | ||
|
||
// let's see if it does | ||
logger2.log("tag", Collections.<String, Object>emptyMap()); | ||
} | ||
} |