diff --git a/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/FileUtils.java b/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/FileUtils.java new file mode 100644 index 00000000..95a4228a --- /dev/null +++ b/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/FileUtils.java @@ -0,0 +1,61 @@ +/* + * Copyright 2013-2019 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 + * + * https://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, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.cloud.commons; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; + +/** + * FileUtils. copy from apache commons.io. + * @author theonefx + */ +public class FileUtils { + + /** + * Reads the contents of a file into a String. The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return the file contents, never {@code null} + * @throws java.io.IOException in case of an I/O error + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of + * {@link java.io .UnsupportedEncodingException} in version 2.2 if the encoding is + * not supported. + * @since 2.3 + */ + public static String readFileToString(final File file, final String encoding) + throws IOException { + return readFileToString(file, Charsets.toCharset(encoding)); + } + + /** + * Reads the contents of a file into a String using the default encoding for the VM. + * The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @return the file contents, never {@code null} + * @throws IOException in case of an I/O error + * @since 1.3.1 + * @deprecated 2.5 use {@link #readFileToString(File, java.nio.charset.Charset)} + * instead (and specify the appropriate encoding) + */ + @Deprecated + public static String readFileToString(final File file) throws IOException { + return readFileToString(file, Charset.defaultCharset()); + } +} diff --git a/spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/test/java/com/alibaba/cloud/sentinel/datasource/SentinelConverterTests.java b/spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/test/java/com/alibaba/cloud/sentinel/datasource/SentinelConverterTests.java index 1053c367..829186d0 100644 --- a/spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/test/java/com/alibaba/cloud/sentinel/datasource/SentinelConverterTests.java +++ b/spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/test/java/com/alibaba/cloud/sentinel/datasource/SentinelConverterTests.java @@ -25,7 +25,7 @@ import com.alibaba.csp.sentinel.slots.block.RuleConstant; import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import org.apache.commons.io.FileUtils; +import com.alibaba.cloud.commons.FileUtils; import org.junit.Test; import org.springframework.util.ResourceUtils; diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/feign/SeataFeignObjectWrapper.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/feign/SeataFeignObjectWrapper.java index ae505058..cf95103c 100644 --- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/feign/SeataFeignObjectWrapper.java +++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/feign/SeataFeignObjectWrapper.java @@ -17,8 +17,8 @@ package com.alibaba.cloud.seata.feign; import feign.Client; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.BeanFactory; import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient; @@ -32,7 +32,7 @@ import org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient; */ public class SeataFeignObjectWrapper { - private static final Log LOG = LogFactory.getLog(SeataFeignObjectWrapper.class); + private static final Logger LOG = LoggerFactory.getLogger(SeataFeignObjectWrapper.class); private final BeanFactory beanFactory;