Skip to content

Commit

Permalink
Merge pull request #84 from twillouer/master
Browse files Browse the repository at this point in the history
MDCCloseable instead of Closeable to avoid throwing of IOException
  • Loading branch information
ceki committed Jan 6, 2015
2 parents 5396fdd + 2897951 commit ed80ded
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions slf4j-api/src/main/java/org/slf4j/MDC.java
Expand Up @@ -70,7 +70,7 @@ public class MDC {
/**
* An adapter to remove the key when done.
*/
private static class MDCCloseable implements Closeable {
public static class MDCCloseable implements Closeable {
private final String key;

private MDCCloseable(String key) {
Expand Down Expand Up @@ -147,7 +147,7 @@ public static void put(String key, String val)
* <p>
* Useful with Java 7 for example :
* <code>
* try(Closeable closeable = MDC.putCloseable(key, value)) {
* try(MDC.MDCCloseable closeable = MDC.putCloseable(key, value)) {
* ....
* }
* </code>
Expand All @@ -160,7 +160,7 @@ public static void put(String key, String val)
* @throws IllegalArgumentException
* in case the "key" parameter is null
*/
public static Closeable putCloseable(String key, String val)
public static MDCCloseable putCloseable(String key, String val)
throws IllegalArgumentException {
put(key, val);
return new MDCCloseable(key);
Expand Down
4 changes: 2 additions & 2 deletions slf4j-nop/src/test/java/org/slf4j/InvocationTest.java
Expand Up @@ -120,8 +120,8 @@ public void testMDC() {
MDC.clear();
}

public void testMDCCloseable() throws IOException {
Closeable closeable = MDC.putCloseable("k", "v");
public void testMDCCloseable() {
MDC.MDCCloseable closeable = MDC.putCloseable("k", "v");
assertNull(MDC.get("k"));
closeable.close();
assertNull(MDC.get("k"));
Expand Down

0 comments on commit ed80ded

Please sign in to comment.