mirror of
https://github.com/apache/rocketmq.git
synced 2026-08-28 20:09:14 +08:00
[ISSUE #4335] Replace deprecated api in cl
This commit is contained in:
+1
-1
@@ -72,7 +72,7 @@ public class JDBCTransactionStore implements TransactionStore {
|
||||
|
||||
private boolean loadDriver() {
|
||||
try {
|
||||
Class.forName(this.jdbcTransactionStoreConfig.getJdbcDriverClass()).newInstance();
|
||||
Class.forName(this.jdbcTransactionStoreConfig.getJdbcDriverClass()).getDeclaredConstructor().newInstance();
|
||||
log.info("Loaded the appropriate driver, {}",
|
||||
this.jdbcTransactionStoreConfig.getJdbcDriverClass());
|
||||
return true;
|
||||
|
||||
@@ -173,7 +173,7 @@ public class ServiceProvider {
|
||||
serviceClazz.getName(),
|
||||
objectId(serviceClazz.getClassLoader()), clazz.getName());
|
||||
}
|
||||
return (T)serviceClazz.newInstance();
|
||||
return (T)serviceClazz.getDeclaredConstructor().newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
if (classLoader == thisClassLoader) {
|
||||
// Nothing more to try, onwards.
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ public class FastCodesHeaderTest {
|
||||
private void check(RemotingCommand command, List<Field> fields,
|
||||
Class<? extends CommandCustomHeader> classHeader) throws Exception {
|
||||
CommandCustomHeader o1 = command.decodeCommandCustomHeader(classHeader, false);
|
||||
CommandCustomHeader o2 = classHeader.newInstance();
|
||||
CommandCustomHeader o2 = classHeader.getDeclaredConstructor().newInstance();
|
||||
((FastCodesHeader)o2).decode(command.getExtFields());
|
||||
for (Field f : fields) {
|
||||
Object value1 = f.get(o1);
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class BeanUtils {
|
||||
public static <T> T populate(final Properties properties, final Class<T> clazz) {
|
||||
T obj = null;
|
||||
try {
|
||||
obj = clazz.newInstance();
|
||||
obj = clazz.getDeclaredConstructor().newInstance();
|
||||
return populate(properties, obj);
|
||||
} catch (Throwable e) {
|
||||
log.warn("Error occurs !", e);
|
||||
@@ -98,7 +98,7 @@ public final class BeanUtils {
|
||||
public static <T> T populate(final KeyValue properties, final Class<T> clazz) {
|
||||
T obj = null;
|
||||
try {
|
||||
obj = clazz.newInstance();
|
||||
obj = clazz.getDeclaredConstructor().newInstance();
|
||||
return populate(properties, obj);
|
||||
} catch (Throwable e) {
|
||||
log.warn("Error occurs !", e);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.apache.rocketmq.remoting.protocol;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
@@ -123,12 +124,16 @@ public class RemotingCommand {
|
||||
|
||||
if (classHeader != null) {
|
||||
try {
|
||||
CommandCustomHeader objectHeader = classHeader.newInstance();
|
||||
CommandCustomHeader objectHeader = classHeader.getDeclaredConstructor().newInstance();
|
||||
cmd.customHeader = objectHeader;
|
||||
} catch (InstantiationException e) {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
return null;
|
||||
} catch (NoSuchMethodException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,11 +248,15 @@ public class RemotingCommand {
|
||||
boolean useFastEncode) throws RemotingCommandException {
|
||||
CommandCustomHeader objectHeader;
|
||||
try {
|
||||
objectHeader = classHeader.newInstance();
|
||||
objectHeader = classHeader.getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
return null;
|
||||
} catch (NoSuchMethodException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.extFields != null) {
|
||||
|
||||
Reference in New Issue
Block a user