INT-4054: Eliminate usage of slf4j
JIRA: https://jira.spring.io/browse/INT-4054
Fixes GH-1833 (https://github.com/spring-projects/spring-integration/issues/1833)
The `DefaultCandidate` pulled requirement for the `slf4j` dependency via its `Logger` and `LoggerFactory` usage.
* Change `slf4j` to the standard Commons Logging
* Exclude `slf4j` transitive dependencies from `optional` direct dependencies like `reactor` and `json-path`
* Since they are `optional` it is safe to exclude their transitives to force our source code to be free from unexpected dependencies.
Anyway they don't appear in the target application as a SI transitives and end-user is forced to pull them manually to switch on the desired features.
If there is need in the `slf4j` for target application, it must be pulled manually as well.
**Cherry-pick to 4.2.x**
(cherry picked from commit fe5ff04)
This commit is contained in:
10
build.gradle
10
build.gradle
@@ -302,9 +302,15 @@ project('spring-integration-core') {
|
||||
compile "org.springframework:spring-tx:$springVersion"
|
||||
compile "org.springframework.retry:spring-retry:$springRetryVersion"
|
||||
// compile ("org.springframework.cloud:spring-cloud-cluster-core:$springCloudClusterVersion", optional)
|
||||
compile ("io.projectreactor:reactor-stream:$reactorVersion", optional)
|
||||
compile ("io.projectreactor:reactor-stream:$reactorVersion") {
|
||||
optional it
|
||||
exclude group: 'org.slf4j', module: 'slf4j-api'
|
||||
}
|
||||
compile("com.fasterxml.jackson.core:jackson-databind:$jackson2Version", optional)
|
||||
compile("com.jayway.jsonpath:json-path:$jsonpathVersion", optional)
|
||||
compile("com.jayway.jsonpath:json-path:$jsonpathVersion") {
|
||||
optional it
|
||||
exclude group: 'org.slf4j', module: 'slf4j-api'
|
||||
}
|
||||
compile("io.fastjson:boon:$boonVersion", optional)
|
||||
compile("com.esotericsoftware:kryo-shaded:$kryoShadedVersion", optional)
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -13,18 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.leader;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Simple {@link Candidate} for leadership.
|
||||
* This implementation simply logs when it is elected and when its leadership is revoked.
|
||||
*
|
||||
* @author Janne Valkealahti
|
||||
* @author Artem Bilan
|
||||
* @since 4.2
|
||||
*/
|
||||
public class DefaultCandidate extends AbstractCandidate {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private volatile Context leaderContext;
|
||||
|
||||
@@ -47,13 +52,17 @@ public class DefaultCandidate extends AbstractCandidate {
|
||||
|
||||
@Override
|
||||
public void onGranted(Context ctx) {
|
||||
logger.info("{} has been granted leadership; context: {}", this, ctx);
|
||||
leaderContext = ctx;
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
this.logger.info(this + " has been granted leadership; context: " + ctx);
|
||||
}
|
||||
this.leaderContext = ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRevoked(Context ctx) {
|
||||
logger.info("{} leadership has been revoked", this, ctx);
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
this.logger.info(this + " leadership has been revoked: " + ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,8 +72,8 @@ public class DefaultCandidate extends AbstractCandidate {
|
||||
* leader initiator.
|
||||
*/
|
||||
public void yieldLeadership() {
|
||||
if (leaderContext != null) {
|
||||
leaderContext.yield();
|
||||
if (this.leaderContext != null) {
|
||||
this.leaderContext.yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user