Skip to content

Commit

Permalink
Merge pull request #10544 from alibaba/v1.x-develop
Browse files Browse the repository at this point in the history
V1.x develop
  • Loading branch information
KomachiSion committed May 25, 2023
2 parents 4fe9304 + 8dafd78 commit 08e3507
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 19 deletions.
1 change: 1 addition & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<packaging>jar</packaging>

<name>nacos-api ${project.version}</name>
<description>Nacos api module.</description>
<url>http://nacos.io</url>
<build>
<plugins>
Expand Down
1 change: 1 addition & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<packaging>jar</packaging>

<name>nacos-client ${project.version}</name>
<description>Nacos client module.</description>
<url>http://nacos.io</url>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public NamingProxy(String namespaceId, String endpoint, String serverList, Prope
}
}
this.initRefreshTask();
injectRoleName();
}

private void initRefreshTask() {
Expand Down Expand Up @@ -644,7 +645,6 @@ private void injectSecurityInfo(Map<String, String> params, Header header) {
}
try {
// Inject ak/sk if exist:
injectRoleName();
String ak = getAccessKey();
String sk = getSecretKey();
params.put("app", AppNameUtils.getAppName());
Expand Down Expand Up @@ -740,8 +740,10 @@ private void injectRoleName() {
if (null != StsConfig.getInstance().getRamRoleName()) {
return;
}
String roleName = properties.getProperty(PropertyKeyConst.RAM_ROLE_NAME, "");
StsConfig.getInstance().setRamRoleName(roleName);
String roleName = properties.getProperty(PropertyKeyConst.RAM_ROLE_NAME);
if (StringUtils.isNotEmpty(roleName)) {
StsConfig.getInstance().setRamRoleName(roleName);
}
}

public String getAccessKey() {
Expand Down
1 change: 1 addition & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<packaging>jar</packaging>

<name>nacos-common ${project.version}</name>
<description>Nacos common module.</description>
<url>http://nacos.io</url>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.alibaba.nacos.consistency.serialize;

import com.alibaba.nacos.api.exception.runtime.NacosDeserializationException;
import com.alibaba.nacos.common.utils.ByteUtils;
import com.alibaba.nacos.consistency.Serializer;
import com.caucho.hessian.io.Hessian2Input;
Expand All @@ -35,7 +36,7 @@
@SuppressWarnings("all")
public class HessianSerializer implements Serializer {

private SerializerFactory serializerFactory = new SerializerFactory();
private SerializerFactory serializerFactory = new NacosHessianSerializerFactory();

public HessianSerializer() {
}
Expand All @@ -47,7 +48,12 @@ public <T> T deserialize(byte[] data) {

@Override
public <T> T deserialize(byte[] data, Class<T> cls) {
return deserialize(data);
T result = deserialize(data);
if (cls.isAssignableFrom(result.getClass())) {
return result;
}
throw new NacosDeserializationException(cls, new ClassCastException(
"%s cannot be cast to %s".format(result.getClass().getCanonicalName(), cls.getCanonicalName())));
}

@Override
Expand All @@ -59,7 +65,7 @@ private <T> T deseiralize0(byte[] data) {
if (ByteUtils.isEmpty(data)) {
return null;
}

Hessian2Input input = new Hessian2Input(new ByteArrayInputStream(data));
input.setSerializerFactory(serializerFactory);
Object resultObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* 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
*
* 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.nacos.consistency.serialize;

import com.caucho.hessian.io.SerializerFactory;

import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;

/**
* Nacos Hessian Serializer Factory.
*
* @author xiweng.yy
*/
public class NacosHessianSerializerFactory extends SerializerFactory {

NacosHessianSerializerFactory() {
super();
super.getClassFactory().setWhitelist(true);
allowBasicType();
allowCollections();
allowConcurrent();
allowTime();
super.getClassFactory().allow("com.alibaba.nacos.*");
}

private void allowBasicType() {
super.getClassFactory().allow(boolean.class.getCanonicalName());
super.getClassFactory().allow(byte.class.getCanonicalName());
super.getClassFactory().allow(char.class.getCanonicalName());
super.getClassFactory().allow(double.class.getCanonicalName());
super.getClassFactory().allow(float.class.getCanonicalName());
super.getClassFactory().allow(int.class.getCanonicalName());
super.getClassFactory().allow(long.class.getCanonicalName());
super.getClassFactory().allow(short.class.getCanonicalName());
super.getClassFactory().allow(Boolean.class.getCanonicalName());
super.getClassFactory().allow(Byte.class.getCanonicalName());
super.getClassFactory().allow(Character.class.getCanonicalName());
super.getClassFactory().allow(Double.class.getCanonicalName());
super.getClassFactory().allow(Float.class.getCanonicalName());
super.getClassFactory().allow(Integer.class.getCanonicalName());
super.getClassFactory().allow(Long.class.getCanonicalName());
super.getClassFactory().allow(Short.class.getCanonicalName());

super.getClassFactory().allow(Number.class.getCanonicalName());
super.getClassFactory().allow(Class.class.getCanonicalName());
super.getClassFactory().allow(String.class.getCanonicalName());
}

private void allowCollections() {
super.getClassFactory().allow(List.class.getCanonicalName());
super.getClassFactory().allow(ArrayList.class.getCanonicalName());
super.getClassFactory().allow(LinkedList.class.getCanonicalName());

super.getClassFactory().allow(Set.class.getCanonicalName());
super.getClassFactory().allow(HashSet.class.getCanonicalName());
super.getClassFactory().allow(LinkedHashSet.class.getCanonicalName());
super.getClassFactory().allow(TreeSet.class.getCanonicalName());

super.getClassFactory().allow(Map.class.getCanonicalName());
super.getClassFactory().allow(HashMap.class.getCanonicalName());
super.getClassFactory().allow(LinkedHashMap.class.getCanonicalName());
super.getClassFactory().allow(TreeMap.class.getCanonicalName());
super.getClassFactory().allow(WeakHashMap.class.getCanonicalName());

super.getClassFactory().allow("java.util.Arrays$ArrayList");
super.getClassFactory().allow("java.util.Collections$EmptyList");
super.getClassFactory().allow("java.util.Collections$EmptyMap");
super.getClassFactory().allow("java.util.Collections$SingletonSet");
super.getClassFactory().allow("java.util.Collections$SingletonList");
super.getClassFactory().allow("java.util.Collections$UnmodifiableCollection");
super.getClassFactory().allow("java.util.Collections$UnmodifiableList");
super.getClassFactory().allow("java.util.Collections$UnmodifiableMap");
super.getClassFactory().allow("java.util.Collections$UnmodifiableNavigableMap");
super.getClassFactory().allow("java.util.Collections$UnmodifiableNavigableSet");
super.getClassFactory().allow("java.util.Collections$UnmodifiableRandomAccessList");
super.getClassFactory().allow("java.util.Collections$UnmodifiableSet");
super.getClassFactory().allow("java.util.Collections$UnmodifiableSortedMap");
super.getClassFactory().allow("java.util.Collections$UnmodifiableSortedSet");
}

private void allowConcurrent() {
super.getClassFactory().allow(AtomicBoolean.class.getCanonicalName());
super.getClassFactory().allow(AtomicInteger.class.getCanonicalName());
super.getClassFactory().allow(AtomicLong.class.getCanonicalName());
super.getClassFactory().allow(AtomicReference.class.getCanonicalName());

super.getClassFactory().allow(ConcurrentMap.class.getCanonicalName());
super.getClassFactory().allow(ConcurrentHashMap.class.getCanonicalName());
super.getClassFactory().allow(ConcurrentSkipListMap.class.getCanonicalName());
super.getClassFactory().allow(CopyOnWriteArrayList.class.getCanonicalName());
}

private void allowTime() {
super.getClassFactory().allow(SimpleDateFormat.class.getCanonicalName());
super.getClassFactory().allow(DateTimeFormatter.class.getCanonicalName());
super.getClassFactory().allow(Instant.class.getCanonicalName());
super.getClassFactory().allow(LocalDate.class.getCanonicalName());
super.getClassFactory().allow(LocalDateTime.class.getCanonicalName());
super.getClassFactory().allow(LocalTime.class.getCanonicalName());
super.getClassFactory().allow(TimeUnit.class.getCanonicalName());
super.getClassFactory().allow(Date.class.getCanonicalName());
super.getClassFactory().allow(Calendar.class.getCanonicalName());
}
}
2 changes: 1 addition & 1 deletion distribution/bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health,${BASE_DIR}/plugi
JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}"
JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/target/${SERVER}.jar"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} --spring.config.additional-location=optional:${CUSTOM_SEARCH_LOCATIONS}"
JAVA_OPT="${JAVA_OPT} --spring.config.additional-location=${CUSTOM_SEARCH_LOCATIONS}"
JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/nacos-logback.xml"
JAVA_OPT="${JAVA_OPT} --server.max-http-header-size=524288"

Expand Down
24 changes: 12 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@

<name>Alibaba NACOS ${project.version}</name>
<description>Top Nacos project pom.xml file</description>
<url>http://nacos.io</url>
<url>https://nacos.io</url>
<prerequisites>
<maven>3.2.5</maven>
</prerequisites>

<scm>
<url>git@github.com:alibaba/nacos.git</url>
<connection>scm:git@github.com:alibaba/nacos.git</connection>
<developerConnection>scm:git@github.com:alibaba/nacos.git</developerConnection>
<tag>nacos-all-${revision}</tag>
</scm>

<mailingLists>
<mailingList>
<name>Development List</name>
Expand All @@ -59,24 +59,24 @@
<post>commits-nacos@googlegroups.com</post>
</mailingList>
</mailingLists>

<developers>
<developer>
<id>Alibaba Nacos</id>
<name>Nacos</name>
<url>http://nacos.io</url>
<url>https://nacos.io</url>
<email>nacos_dev@linux.alibaba.com</email>
</developer>
</developers>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>

<organization>
<name>Alibaba Group</name>
<url>https://github.com/alibaba</url>
Expand All @@ -88,7 +88,7 @@
</issueManagement>

<properties>
<revision>1.4.5</revision>
<revision>1.4.6</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Compiler settings properties -->
Expand All @@ -101,7 +101,7 @@
<!-- Exclude all generated code -->
<sonar.jacoco.itReportPath>${project.basedir}/../test/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.exclusions>file:**/generated-sources/**,**/test/**</sonar.exclusions>

<!-- plugin version -->
<versions-maven-plugin.version>2.2</versions-maven-plugin.version>
<dependency-mediator-maven-plugin.version>1.0.2</dependency-mediator-maven-plugin.version>
Expand All @@ -126,17 +126,17 @@
<!-- dependency version related to plugin -->
<extra-enforcer-rules.version>1.0-beta-4</extra-enforcer-rules.version>
<p3c-pmd.version>1.3.0</p3c-pmd.version>

<!-- dependency version -->
<spring-boot-dependencies.version>2.6.8</spring-boot-dependencies.version>
<spring-boot-dependencies.version>2.7.11</spring-boot-dependencies.version>
<servlet-api.version>3.0</servlet-api.version>
<commons-lang3.version>3.4</commons-lang3.version>
<commons-io.version>2.7</commons-io.version>
<commons-collections.version>3.2.2</commons-collections.version>
<commons-logging.version>1.2</commons-logging.version>
<commons-dbcp.version>1.4</commons-dbcp.version>
<commons-cli.version>1.2</commons-cli.version>
<slf4j-api.version>1.7.7</slf4j-api.version>
<slf4j-api.version>1.7.26</slf4j-api.version>
<logback.version>1.2.9</logback.version>
<log4j.version>2.17.1</log4j.version>

Expand Down

0 comments on commit 08e3507

Please sign in to comment.