Skip to content

Commit

Permalink
Merge pull request #23 from mercyblitz/dev-1.x
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
mercyblitz authored Jan 13, 2025
2 parents eb5f3f1 + 79b78e1 commit af380b7
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 33 deletions.
21 changes: 20 additions & 1 deletion microsphere-spring-cloud-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@
<scope>test</scope>
</dependency>

</dependencies>
<!-- Netflix Eureka Client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-client</artifactId>
<scope>test</scope>
</dependency>

<!-- Alibaba Nacos Discovery -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.springframework.cloud.client.CommonsClientAutoConfiguration;
import org.springframework.cloud.client.actuator.FeaturesEndpoint;
import org.springframework.cloud.client.actuator.HasFeatures;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistration;
import org.springframework.core.annotation.AliasFor;

import java.lang.annotation.Documented;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package io.microsphere.spring.cloud.client.service.registry.autoconfigure;

import io.microsphere.logging.Logger;
import io.microsphere.logging.LoggerFactory;
import io.microsphere.spring.cloud.client.service.registry.condition.ConditionalOnAutoServiceRegistrationEnabled;
import io.microsphere.spring.web.event.WebEndpointMappingsReadyEvent;
import io.microsphere.spring.web.metadata.WebEndpointMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -104,8 +104,8 @@ private void excludeMappings(Set<WebEndpointMapping> mappings) {
|| isDispatcherServletMapping(mapping, patterns)
|| isActuatorWebEndpointMapping(patterns)
) {
if (logger.isDebugEnabled()) {
logger.debug("The '{}' was removed", mapping);
if (logger.isTraceEnabled()) {
logger.trace("The '{}' was removed", mapping);
}
iterator.remove();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.microsphere.spring.cloud.client.service.registry.endpoint;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.microsphere.logging.Logger;
import io.microsphere.logging.LoggerFactory;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration;
Expand All @@ -24,10 +24,14 @@ public boolean stop() {
boolean isRunning = isRunning();
if (isRunning) {
serviceRegistry.deregister(registration);
logger.info("Service[name : '{}'] is deregistered!", applicationName);
if(logger.isInfoEnabled()) {
logger.info("Service[name : '{}'] is deregistered!", applicationName);
}
setRunning(false);
} else {
logger.warn("Service[name : '{}'] is not registered, deregistration can't be executed!", applicationName);
if (logger.isWarnEnabled()) {
logger.warn("Service[name : '{}'] is not registered, deregistration can't be executed!", applicationName);
}
}
return isRunning;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.microsphere.spring.cloud.client.service.registry.endpoint;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.microsphere.logging.Logger;
import io.microsphere.logging.LoggerFactory;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
Expand Down Expand Up @@ -55,9 +55,13 @@ public boolean start() {
if (!isRunning) {
serviceRegistry.register(registration);
setRunning(true);
logger.debug("Service[name : '{}'] is registered!", applicationName);
if(logger.isTraceEnabled()) {
logger.trace("Service[name : '{}'] is registered!", applicationName);
}
} else {
logger.warn("Service[name : '{}'] was registered!", applicationName);
if(logger.isWarnEnabled()) {
logger.warn("Service[name : '{}'] was registered!", applicationName);
}
}
return isRunning;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.microsphere.logging.Logger;
import io.microsphere.logging.LoggerFactory;
import io.microsphere.spring.web.metadata.WebEndpointMapping;
import io.microsphere.util.BaseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.ServiceInstance;

import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package io.microsphere.spring.cloud.fault.tolerance.tomcat.event;


import io.microsphere.logging.Logger;
import io.microsphere.logging.LoggerFactory;
import org.apache.catalina.connector.Connector;
import org.apache.coyote.AbstractProtocol;
import org.apache.coyote.ProtocolHandler;
import org.apache.coyote.http11.AbstractHttp11Protocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
Expand Down Expand Up @@ -85,19 +85,23 @@ private void initCurrentServerProperties() {
}

private boolean isBeanPresent(Class<?> beanType) {
return context.getBeanProvider(ConfigurationPropertiesRebinder.class).getIfAvailable() != null;
return context.getBeanProvider(beanType).getIfAvailable() != null;
}

@Override
public void onApplicationEvent(EnvironmentChangeEvent event) {
if (!isSourceFrom(event)) {
logger.debug("Current context[id : '{}'] receives the other changed property names : {}", context.getId(), event.getKeys());
if(logger.isTraceEnabled()) {
logger.trace("Current context[id : '{}'] receives the other changed property names : {}", context.getId(), event.getKeys());
}
return;
}

Set<String> serverPropertyNames = filterServerPropertyNames(event);
if (serverPropertyNames.isEmpty()) {
logger.debug("Current context[id : '{}'] does not receive the property change of ServerProperties, keys : {}", context.getId(), event.getKeys());
if(logger.isTraceEnabled()) {
logger.trace("Current context[id : '{}'] does not receive the property change of ServerProperties, keys : {}", context.getId(), event.getKeys());
}
return;
}

Expand All @@ -123,7 +127,9 @@ private boolean isServerPropertyName(String propertyName) {

private void configureTomcatIfChanged(Set<String> serverPropertyNames) {
ServerProperties refreshableServerProperties = getRefreshableServerProperties(serverPropertyNames);
logger.debug("The ServerProperties property is changed to: {}", getProperties(environment, serverPropertyNames));
if(logger.isTraceEnabled()) {
logger.debug("The ServerProperties property is changed to: {}", getProperties(environment, serverPropertyNames));
}
configureConnector(refreshableServerProperties);
// Reset current ServerProperties
initCurrentServerProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.microsphere.spring.cloud.client.service.registry.event.RegistrationPreRegisteredEvent;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
Expand All @@ -22,7 +21,6 @@
import org.springframework.cloud.commons.util.UtilAutoConfiguration;
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration;
import org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration;
import org.springframework.context.ApplicationListener;
import org.springframework.test.context.ContextConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.microsphere.spring.webmvc.annotation.EnableWebMvcExtension;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -38,6 +39,7 @@
classes = {WebMvcServiceRegistryAutoConfigurationTest.class},
properties = {
"microsphere.spring.cloud.simple.enabled=true",
"spring.cloud.service-registry.auto-registration.enabled=true",
"spring.cloud.kubernetes.enabled=false",
"kubernetes.informer.enabled=false",
"kubernetes.manifests.enabled=false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import feign.codec.Decoder;
import feign.codec.Encoder;
import feign.codec.ErrorDecoder;
import io.microsphere.spring.cloud.openfeign.components.*;
import io.microsphere.spring.cloud.openfeign.components.DecoratedContract;
import io.microsphere.spring.cloud.openfeign.components.DecoratedDecoder;
import io.microsphere.spring.cloud.openfeign.components.DecoratedEncoder;
import io.microsphere.spring.cloud.openfeign.components.DecoratedErrorDecoder;
import io.microsphere.spring.cloud.openfeign.components.DecoratedFeignComponent;
import io.microsphere.spring.cloud.openfeign.components.DecoratedQueryMapEncoder;
import io.microsphere.spring.cloud.openfeign.components.DecoratedRetryer;
import org.springframework.beans.BeansException;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.cloud.openfeign.FeignContext;
Expand Down
15 changes: 7 additions & 8 deletions microsphere-spring-cloud-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

<properties>
<!-- BOM versions -->
<spring-boot.version>2.7.18</spring-boot.version>
<spring-cloud.version>2021.0.9</spring-cloud.version>
<spring-cloud-alibaba.version>2021.0.6.1</spring-cloud-alibaba.version>
<microsphere-spring-boot.version>0.1.1</microsphere-spring-boot.version>
<testcontainers.version>1.20.1</testcontainers.version>
</properties>
Expand Down Expand Up @@ -103,15 +100,15 @@
<properties>
<spring-boot.version>2.3.12.RELEASE</spring-boot.version>
<spring-cloud.version>Hoxton.SR12</spring-cloud.version>
<spring-cloud-alibaba.version>2.2.9.RELEASE</spring-cloud-alibaba.version>
<spring-cloud-alibaba.version>2.2.10</spring-cloud-alibaba.version>
</properties>
</profile>

<profile>
<id>spring-cloud-2020</id>
<properties>
<spring-boot.version>2.4.13</spring-boot.version>
<spring-cloud.version>2020.0.6</spring-cloud.version>
<spring-cloud.version>2020.0.5</spring-cloud.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
</properties>
</profile>
Expand All @@ -121,14 +118,16 @@
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<spring-boot.version>2.6.15</spring-boot.version>
<spring-cloud.version>2021.0.9</spring-cloud.version>
<spring-cloud-alibaba.version>2021.0.6.1</spring-cloud-alibaba.version>
</properties>
</profile>

<!-- Spring Cloud Netflix Eureka -->
<profile>
<id>spring-cloud-netflix-eureka</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down

0 comments on commit af380b7

Please sign in to comment.