check style (#1299)

* style(hippo4j-threadpool-infra-common): checke style update

* style(hippo4j-threadpool-infra-common): checke style update

* style(hippo4j-threadpool-infra-common): check style log (info --> error)

* style(hippo4j-threadpool-infra-common): @Slf4j

* style(hippo4j-threadpool-infra-common): check style update
pull/1321/head
yhc777 2 years ago committed by GitHub
parent 4fae1003b2
commit 5d79520c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,5 +32,11 @@
<suppress checks="TypeName" files="SpringBootConfig.java"/>
<suppress checks="ReturnCount" files="Hippo4jAgent.java"/>
<suppress checks="StaticVariableName" files="Hippo4jAgent.java"/>
<suppress checks="StaticVariableName" files="ExtensionRegistry.java"/>
<suppress checks="MagicNumber" files="IdUtil.java"/>
<suppress checks="MagicNumber" files="IoUtil.java"/>
<suppress checks="ReturnCount" files="StringUtil.java"/>
<suppress checks="ReturnCount" files="MapUtil.java"/>
<suppress checks="ReturnCount" files="ReflectUtil.java"/>
<suppress checks="InnerAssignment" files="IoUtil.java"/>
<suppress checks="ParameterNumber" files="HttpUtil.java"/>
</suppressions>

@ -20,27 +20,27 @@ package cn.hippo4j.common.constant;
/**
* Http header constants.
*/
public interface HttpHeaderConstants {
public class HttpHeaderConstants {
String CLIENT_VERSION_HEADER = "Client-Version";
public static final String CLIENT_VERSION_HEADER = "Client-Version";
String USER_AGENT_HEADER = "User-Agent";
public static final String USER_AGENT_HEADER = "User-Agent";
String REQUEST_SOURCE_HEADER = "Request-Source";
public static final String REQUEST_SOURCE_HEADER = "Request-Source";
String CONTENT_TYPE = "Content-Type";
public static final String CONTENT_TYPE = "Content-Type";
String CONTENT_LENGTH = "Content-Length";
public static final String CONTENT_LENGTH = "Content-Length";
String ACCEPT_CHARSET = "Accept-Charset";
public static final String ACCEPT_CHARSET = "Accept-Charset";
String ACCEPT_ENCODING = "Accept-Encoding";
public static final String ACCEPT_ENCODING = "Accept-Encoding";
String CONTENT_ENCODING = "Content-Encoding";
public static final String CONTENT_ENCODING = "Content-Encoding";
String CONNECTION = "Requester";
public static final String CONNECTION = "Requester";
String REQUEST_ID = "RequestId";
public static final String REQUEST_ID = "RequestId";
String REQUEST_MODULE = "Request-Module";
public static final String REQUEST_MODULE = "Request-Module";
}

@ -17,8 +17,13 @@
package cn.hippo4j.common.constant;
/**
* Magic Number Constants
*/
public class MagicNumberConstants {
public static final int INDEX_NEGATIVE_1 = -1;
public static final int INDEX_0 = 0;
public static final int INDEX_1 = 1;
@ -27,6 +32,10 @@ public class MagicNumberConstants {
public static final int INDEX_3 = 3;
public static final int INDEX_10 = 10;
public static final int SIZE_4 = 4;
public static final long LONG_5 = 5L;
}

@ -20,7 +20,10 @@ package cn.hippo4j.common.executor.support;
import cn.hippo4j.common.extension.spi.ServiceLoaderRegistry;
import lombok.Getter;
import java.util.*;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Stream;

@ -29,7 +29,7 @@ import java.util.stream.Collectors;
/**
* Dynamic thread-pool SPI service loader.
*/
public class ServiceLoaderRegistry {
public final class ServiceLoaderRegistry {
/**
* safe container

@ -39,7 +39,7 @@ import java.util.Set;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BeanUtil {
protected static Mapper BEAN_MAPPER_BUILDER;
protected static final Mapper BEAN_MAPPER_BUILDER;
static {
BEAN_MAPPER_BUILDER = DozerBeanMapperBuilder.buildDefault();

@ -17,6 +17,8 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.constant.MagicNumberConstants;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -164,7 +166,7 @@ public class CollectionUtil {
private static int computeArrayListCapacity(int arraySize) {
checkNonnegative(arraySize);
// TODO(kevinb): Figure out the right behavior, and document it
return saturatedCast(5L + arraySize + (arraySize / 10));
return saturatedCast(MagicNumberConstants.LONG_5 + arraySize + (arraySize / MagicNumberConstants.INDEX_10));
}
private static void checkNonnegative(int value) {

@ -19,6 +19,7 @@ package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.constant.Constants;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@ -47,6 +48,7 @@ import java.util.zip.GZIPOutputStream;
*
* @author nacos
*/
@Slf4j
public class IoUtil {
/**
@ -98,7 +100,7 @@ public class IoUtil {
try (GZIPOutputStream gzip = new GZIPOutputStream(out)) {
gzip.write(str.getBytes(encoding));
} catch (Exception e) {
e.printStackTrace();
log.error("gzip write is fail: {}", e.getMessage());
}
return out.toByteArray();
}

@ -181,11 +181,7 @@ public class MapUtil {
* @return
*/
private static boolean checkKey(String key, String filters) {
if (key.contains(filters)) {
return true;
} else {
return false;
}
return key.contains(filters);
}
/**

@ -17,6 +17,8 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.constant.MagicNumberConstants;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -354,10 +356,10 @@ public class StringUtil {
return EMPTY;
}
int pos = str.indexOf(symbol);
if (-1 == pos) {
if (MagicNumberConstants.INDEX_NEGATIVE_1 == pos) {
return str;
}
if (0 == pos) {
if (MagicNumberConstants.INDEX_0 == pos) {
return EMPTY;
}
return str.substring(0, pos);

@ -34,7 +34,7 @@ import java.util.TreeMap;
*
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
public class Header {
public final class Header {
public static final Header EMPTY = Header.newInstance();

Loading…
Cancel
Save