diff --git a/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/utils/BeanCopyUtils.java b/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/utils/BeanCopyUtils.java index 2ed923b8..a8e1b861 100644 --- a/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/utils/BeanCopyUtils.java +++ b/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/utils/BeanCopyUtils.java @@ -33,7 +33,7 @@ public class BeanCopyUtils public static T copyProperties(Object source, Class targetClazz) { /* 34 */ T target = null; try { -/* 36 */ target = targetClazz.newInstance(); +/* 36 */ target = targetClazz.getDeclaredConstructor().newInstance(); /* 37 */ BeanUtils.copyProperties(source, target); /* 38 */ } catch (Exception e) { /* 39 */ throw new RuntimeException(e); @@ -101,7 +101,7 @@ if (!CollectionUtils.isEmpty(list)) { for (V source : list) { E target = null; try { -target = clazz.newInstance(); +target = clazz.getDeclaredConstructor().newInstance(); BeanUtils.copyProperties(source, target); } catch (Exception e) { throw new RuntimeException(e); diff --git a/maven-cloudwalk-legacy-public/cloudwalk-common-serial/src/main/java/cn/cloudwalk/serial/strategy/ServerIdStrategyBeanConfig.java b/maven-cloudwalk-legacy-public/cloudwalk-common-serial/src/main/java/cn/cloudwalk/serial/strategy/ServerIdStrategyBeanConfig.java index 321fd1f6..b3b73e6b 100644 --- a/maven-cloudwalk-legacy-public/cloudwalk-common-serial/src/main/java/cn/cloudwalk/serial/strategy/ServerIdStrategyBeanConfig.java +++ b/maven-cloudwalk-legacy-public/cloudwalk-common-serial/src/main/java/cn/cloudwalk/serial/strategy/ServerIdStrategyBeanConfig.java @@ -32,7 +32,7 @@ ServerIdStrategyEnum.getServerIdStrategyEnum(serialProperties.getServerIdStrateg beanClassName = Class.forName(ServerIdStrategyEnum.getServerIdStrategyEnum(serialProperties.getServerIdStrategy().getCode()).getBeanName()); } } -return (ServerIdStrategy)beanClassName.newInstance(); +return (ServerIdStrategy)beanClassName.getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/maven-cloudwalk-legacy-public/cloudwalk-common-web/src/main/java/cn/cloudwalk/web/filter/CloudwalkContextParameterFilter.java b/maven-cloudwalk-legacy-public/cloudwalk-common-web/src/main/java/cn/cloudwalk/web/filter/CloudwalkContextParameterFilter.java index 63e08ef2..0a03ea01 100644 --- a/maven-cloudwalk-legacy-public/cloudwalk-common-web/src/main/java/cn/cloudwalk/web/filter/CloudwalkContextParameterFilter.java +++ b/maven-cloudwalk-legacy-public/cloudwalk-common-web/src/main/java/cn/cloudwalk/web/filter/CloudwalkContextParameterFilter.java @@ -9,8 +9,6 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -34,7 +32,6 @@ import org.springframework.web.filter.OncePerRequestFilter; public class CloudwalkContextParameterFilter extends OncePerRequestFilter { -private final Logger logger = LoggerFactory.getLogger(getClass()); @@ -75,11 +72,9 @@ this.cloudwalkSessionContextHolder.putSession(sessionObject); try { chain.doFilter((ServletRequest)request, (ServletResponse)response); -} catch (Exception e) { -this.logger.error("参数注册过滤器失败,原因:", e); } finally { this.cloudwalkSessionContextHolder.clearSession(); -} +} } } diff --git a/maven-cloudwalk-legacy-public/cwos-sdk-event/src/main/java/cn/cloudwalk/cwos/client/event/producer/KafkaProducter.java b/maven-cloudwalk-legacy-public/cwos-sdk-event/src/main/java/cn/cloudwalk/cwos/client/event/producer/KafkaProducter.java index fd85d3e9..24d8fbbe 100644 --- a/maven-cloudwalk-legacy-public/cwos-sdk-event/src/main/java/cn/cloudwalk/cwos/client/event/producer/KafkaProducter.java +++ b/maven-cloudwalk-legacy-public/cwos-sdk-event/src/main/java/cn/cloudwalk/cwos/client/event/producer/KafkaProducter.java @@ -10,7 +10,6 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.apache.kafka.clients.producer.KafkaProducer; -import org.apache.kafka.clients.producer.Producer; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.clients.producer.RecordMetadata; @@ -25,7 +24,7 @@ public class KafkaProducter implements MessageProducer { private KafkaProperties kafkaProperties; -private Producer producer; +private KafkaProducer producer; private KafkaProducter(KafkaProperties kafkaProperties) { Properties properties = new Properties(); @@ -49,7 +48,7 @@ properties.put("buffer.memory", Long.valueOf(kafkaProperties.getBufferMemory())) properties.put("key.serializer", kafkaProperties.getKeySerializer()); properties.put("value.serializer", kafkaProperties.getValueSerializer()); this.kafkaProperties = kafkaProperties; -this.producer = (Producer)new KafkaProducer(properties); +this.producer = new KafkaProducer<>(properties); } public static KafkaProducter getInstance(KafkaProperties kafkaProperties) { @@ -60,13 +59,15 @@ return new KafkaProducter(kafkaProperties); public void send(BaseEvent event, String key, String topic) { Integer deviceIdHashCode = Integer.valueOf((event.getDeviceId() != null) ? event.getDeviceId().hashCode() : 0); Integer partition = Integer.valueOf(deviceIdHashCode.intValue() % this.producer.partitionsFor(topic).size()); -Future send = this.producer.send(new ProducerRecord(topic, partition, key, JSONObject.toJSONString(event))); +Future send = + this.producer.send(new ProducerRecord<>(topic, partition, key, JSONObject.toJSONString(event))); try { send.get(1000L, TimeUnit.MILLISECONDS); if (!send.isDone()) { throw new SendFailedException("failed to send kafka"); } } catch (InterruptedException e) { +Thread.currentThread().interrupt(); throw new SendFailedException("failed to send kafka InterruptedException" + e.getMessage()); } catch (ExecutionException e) { throw new SendFailedException("failed to send kafka ExecutionException" + e.getMessage());