Skip to content

Commit

Permalink
fix SLF4J-516
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Jul 11, 2021
1 parent edb09d7 commit 3e2381e
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 14 deletions.
4 changes: 2 additions & 2 deletions slf4j-api/src/main/java/org/slf4j/LoggerFactory.java
Expand Up @@ -114,7 +114,7 @@ private static List<SLF4JServiceProvider> findServiceProviders() {
* <p>
* It is assumed that all versions in the 1.6 are mutually compatible.
*/
static private final String[] API_COMPATIBILITY_LIST = new String[] { "1.8", "1.7" };
static private final String[] API_COMPATIBILITY_LIST = new String[] { "2.0" };

// private constructor prevents instantiation
private LoggerFactory() {
Expand Down Expand Up @@ -294,7 +294,7 @@ private static void emitReplayWarning(int eventCount) {

private final static void versionSanityCheck() {
try {
String requested = PROVIDER.getRequesteApiVersion();
String requested = PROVIDER.getRequestedApiVersion();

boolean match = false;
for (String aAPI_COMPATIBILITY_LIST : API_COMPATIBILITY_LIST) {
Expand Down
Expand Up @@ -12,25 +12,31 @@ public class NOPServiceProvider implements SLF4JServiceProvider {
* against. The value of this field is modified with each major release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
public static String REQUESTED_API_VERSION = "1.8.99"; // !final
public static String REQUESTED_API_VERSION = "2.0.99"; // !final

private ILoggerFactory loggerFactory = new NOPLoggerFactory();
private IMarkerFactory markerFactory = new BasicMarkerFactory();
private MDCAdapter mdcAdapter = new NOPMDCAdapter();


@Override
public ILoggerFactory getLoggerFactory() {
return loggerFactory;
}

@Override
public IMarkerFactory getMarkerFactory() {
return markerFactory;
}


@Override
public MDCAdapter getMDCAdapter() {
return mdcAdapter;
}

public String getRequesteApiVersion() {
@Override
public String getRequestedApiVersion() {
return REQUESTED_API_VERSION;
}

Expand Down
Expand Up @@ -30,7 +30,7 @@ public MDCAdapter getMDCAdapter() {
}

@Override
public String getRequesteApiVersion() {
public String getRequestedApiVersion() {
throw new UnsupportedOperationException();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public interface SLF4JServiceProvider {
*/
public MDCAdapter getMDCAdapter();

public String getRequesteApiVersion();
public String getRequestedApiVersion();

/**
* Initialize the logging back-end.
Expand Down
Expand Up @@ -14,16 +14,18 @@ public class JULServiceProvider implements SLF4JServiceProvider {
* against. The value of this field is modified with each major release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
public static String REQUESTED_API_VERSION = "1.8.99"; // !final
public static String REQUESTED_API_VERSION = "2.0.99"; // !final

private ILoggerFactory loggerFactory;
private IMarkerFactory markerFactory;
private MDCAdapter mdcAdapter;

@Override
public ILoggerFactory getLoggerFactory() {
return loggerFactory;
}

@Override
public IMarkerFactory getMarkerFactory() {
return markerFactory;
}
Expand All @@ -32,10 +34,12 @@ public MDCAdapter getMDCAdapter() {
return mdcAdapter;
}

public String getRequesteApiVersion() {
@Override
public String getRequestedApiVersion() {
return REQUESTED_API_VERSION;
}

@Override
public void initialize() {
loggerFactory = new JDK14LoggerFactory();
markerFactory = new BasicMarkerFactory();
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class Log4j12ServiceProvider implements SLF4JServiceProvider {
* The value of this field is modified with each major release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
public static String REQUESTED_API_VERSION = "1.8.99"; // !final
public static String REQUESTED_API_VERSION = "2.0.99"; // !final

private ILoggerFactory loggerFactory;
private IMarkerFactory markerFactory;
Expand All @@ -37,19 +37,25 @@ public void initialize() {
mdcAdapter = new Log4jMDCAdapter();
}

@Override
public ILoggerFactory getLoggerFactory() {
return loggerFactory;
}


@Override
public IMarkerFactory getMarkerFactory() {
return markerFactory;
}


@Override
public MDCAdapter getMDCAdapter() {
return mdcAdapter;
}

public String getRequesteApiVersion() {
@Override
public String getRequestedApiVersion() {
return REQUESTED_API_VERSION;
}
}
7 changes: 5 additions & 2 deletions slf4j-nop/src/main/java/org/slf4j/nop/NOPServiceProvider.java
Expand Up @@ -15,7 +15,7 @@ public class NOPServiceProvider implements SLF4JServiceProvider {
* The value of this field is modified with each major release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
public static String REQUESTED_API_VERSION = "1.8.99"; // !final
public static String REQUESTED_API_VERSION = "2.0.99"; // !final

private ILoggerFactory loggerFactory = new NOPLoggerFactory();
private IMarkerFactory markerFactory = new BasicMarkerFactory();
Expand All @@ -33,11 +33,14 @@ public MDCAdapter getMDCAdapter() {
return mdcAdapter;
}

public String getRequesteApiVersion() {
@Override
public String getRequestedApiVersion() {
return REQUESTED_API_VERSION;
}

public void initialize() {

}


}
Expand Up @@ -14,7 +14,7 @@ public class SimpleServiceProvider implements SLF4JServiceProvider {
* The value of this field is modified with each major release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
public static String REQUESTED_API_VERSION = "1.8.99"; // !final
public static String REQUESTED_API_VERSION = "2.0.99"; // !final

private ILoggerFactory loggerFactory;
private IMarkerFactory markerFactory;
Expand All @@ -24,15 +24,18 @@ public ILoggerFactory getLoggerFactory() {
return loggerFactory;
}

@Override
public IMarkerFactory getMarkerFactory() {
return markerFactory;
}

@Override
public MDCAdapter getMDCAdapter() {
return mdcAdapter;
}

public String getRequesteApiVersion() {
@Override
public String getRequestedApiVersion() {
return REQUESTED_API_VERSION;
}

Expand Down

0 comments on commit 3e2381e

Please sign in to comment.