Skip to content

Commit de23b55

Browse files
authored
Merge pull request #5498 from tronprotocol/release_v4.7.3
2 parents 9f8cebd + b81a63e commit de23b55

File tree

173 files changed

+835
-677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+835
-677
lines changed

chainbase/src/main/java/org/tron/core/db2/common/TxCacheDB.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ private boolean handleException(Throwable e) {
318318
private void dump() {
319319
if (!isValid.get()) {
320320
logger.info("bloomFilters is not valid.");
321+
return;
321322
}
322323
FileUtil.createDirIfNotExists(this.cacheDir.toString());
323324
logger.info("dump bloomFilters start.");

common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies {
5353
compile 'org.aspectj:aspectjrt:1.8.13'
5454
compile 'org.aspectj:aspectjweaver:1.8.13'
5555
compile 'org.aspectj:aspectjtools:1.8.13'
56-
compile group: 'io.github.tronprotocol', name: 'libp2p', version: '1.2.0',{
56+
compile group: 'com.github.tronprotocol', name: 'libp2p', version: 'test-v2.0.2',{
5757
exclude group: 'io.grpc', module: 'grpc-context'
5858
exclude group: 'io.grpc', module: 'grpc-core'
5959
exclude group: 'io.grpc', module: 'grpc-netty'

framework/src/main/java/org/tron/core/services/filter/HttpApiAccessFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private boolean isDisabled(String endpoint) {
6565
disabled = disabledApiList.contains(endpoint.split("/")[2].toLowerCase());
6666
}
6767
} catch (Exception e) {
68-
logger.error("check isDisabled except, endpoint={}, error is {}", endpoint, e.getMessage());
68+
logger.warn("check isDisabled except, endpoint={}, {}", endpoint, e.getMessage());
6969
}
7070

7171
return disabled;

framework/src/main/java/org/tron/core/services/http/Util.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.commons.lang3.StringUtils;
3131
import org.bouncycastle.util.encoders.Hex;
3232
import org.eclipse.jetty.http.HttpMethod;
33+
import org.eclipse.jetty.http.MimeTypes;
3334
import org.eclipse.jetty.util.MultiMap;
3435
import org.eclipse.jetty.util.StringUtil;
3536
import org.eclipse.jetty.util.UrlEncoded;
@@ -78,8 +79,6 @@ public class Util {
7879
public static final String FUNCTION_SELECTOR = "function_selector";
7980
public static final String FUNCTION_PARAMETER = "parameter";
8081
public static final String CALL_DATA = "data";
81-
public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
82-
public static final String APPLICATION_JSON = "application/json";
8382

8483
public static String printTransactionFee(String transactionFee) {
8584
JSONObject jsonObject = new JSONObject();
@@ -525,7 +524,6 @@ public static byte[] getAddress(HttpServletRequest request) throws Exception {
525524

526525
private static String checkGetParam(HttpServletRequest request, String key) throws Exception {
527526
String method = request.getMethod();
528-
String value = null;
529527

530528
if (HttpMethod.GET.toString().toUpperCase().equalsIgnoreCase(method)) {
531529
return request.getParameter(key);
@@ -535,8 +533,10 @@ private static String checkGetParam(HttpServletRequest request, String key) thro
535533
if (StringUtils.isBlank(contentType)) {
536534
return null;
537535
}
538-
if (APPLICATION_JSON.toLowerCase().contains(contentType)) {
539-
value = getRequestValue(request);
536+
if (contentType.contains(MimeTypes.Type.FORM_ENCODED.asString())) {
537+
return request.getParameter(key);
538+
} else {
539+
String value = getRequestValue(request);
540540
if (StringUtils.isBlank(value)) {
541541
return null;
542542
}
@@ -545,13 +545,10 @@ private static String checkGetParam(HttpServletRequest request, String key) thro
545545
if (jsonObject != null) {
546546
return jsonObject.getString(key);
547547
}
548-
} else if (APPLICATION_FORM_URLENCODED.toLowerCase().contains(contentType)) {
549-
return request.getParameter(key);
550-
} else {
551548
return null;
552549
}
553550
}
554-
return value;
551+
return null;
555552
}
556553

557554
public static String getRequestValue(HttpServletRequest request) throws IOException {

framework/src/test/java/org/tron/common/BaseTest.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package org.tron.common;
22

33
import com.google.protobuf.ByteString;
4-
import java.io.File;
4+
import java.io.IOException;
55
import javax.annotation.Resource;
66
import lombok.extern.slf4j.Slf4j;
7-
import org.apache.commons.lang3.StringUtils;
87
import org.junit.AfterClass;
8+
import org.junit.Assert;
9+
import org.junit.ClassRule;
10+
import org.junit.rules.TemporaryFolder;
911
import org.junit.runner.RunWith;
1012
import org.springframework.test.annotation.DirtiesContext;
1113
import org.springframework.test.context.ContextConfiguration;
1214
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1315
import org.tron.common.crypto.ECKey;
1416
import org.tron.common.parameter.CommonParameter;
15-
import org.tron.common.utils.FileUtil;
1617
import org.tron.common.utils.Sha256Hash;
1718
import org.tron.consensus.base.Param;
1819
import org.tron.core.ChainBaseManager;
@@ -28,22 +29,27 @@
2829
@DirtiesContext
2930
public abstract class BaseTest {
3031

31-
protected static String dbPath;
32+
@ClassRule
33+
public static final TemporaryFolder temporaryFolder = new TemporaryFolder();
34+
3235
@Resource
3336
protected Manager dbManager;
3437
@Resource
3538
protected ChainBaseManager chainBaseManager;
3639

40+
41+
public static String dbPath() {
42+
try {
43+
return temporaryFolder.newFolder().toString();
44+
} catch (IOException e) {
45+
Assert.fail("create temp folder failed");
46+
}
47+
return null;
48+
}
49+
3750
@AfterClass
3851
public static void destroy() {
3952
Args.clearParam();
40-
if (StringUtils.isNotEmpty(dbPath)) {
41-
if (FileUtil.deleteDir(new File(dbPath))) {
42-
logger.info("Release resources successful.");
43-
} else {
44-
logger.info("Release resources failure.");
45-
}
46-
}
4753
}
4854

4955
public Protocol.Block getSignedBlock(ByteString witness, long time, byte[] privateKey) {

framework/src/test/java/org/tron/common/config/args/ArgsTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
package org.tron.common.config.args;
22

3-
import java.io.File;
3+
import java.io.IOException;
44
import org.junit.After;
55
import org.junit.Assert;
66
import org.junit.Before;
7+
import org.junit.Rule;
78
import org.junit.Test;
9+
import org.junit.rules.TemporaryFolder;
810
import org.tron.common.parameter.RateLimiterInitialization;
9-
import org.tron.common.utils.FileUtil;
1011
import org.tron.core.Constant;
1112
import org.tron.core.config.args.Args;
1213

1314

1415
public class ArgsTest {
1516

16-
private static final String dbPath = "output_arg_test";
17+
@Rule
18+
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
1719

1820
@Before
19-
public void init() {
20-
Args.setParam(new String[] {"--output-directory", dbPath, "--p2p-disable", "true",
21+
public void init() throws IOException {
22+
Args.setParam(new String[] {"--output-directory",
23+
temporaryFolder.newFolder().toString(), "--p2p-disable", "true",
2124
"--debug"}, Constant.TEST_CONF);
2225
}
2326

2427
@After
2528
public void destroy() {
2629
Args.clearParam();
27-
FileUtil.deleteDir(new File(dbPath));
2830
}
2931

3032
@Test

framework/src/test/java/org/tron/common/runtime/InheritanceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public class InheritanceTest extends BaseTest {
2525
private static boolean init;
2626

2727
static {
28-
dbPath = "output_InheritanceTest";
29-
Args.setParam(new String[]{"--output-directory", dbPath, "--debug"}, Constant.TEST_CONF);
28+
Args.setParam(new String[]{"--output-directory", dbPath(), "--debug"}, Constant.TEST_CONF);
3029
OWNER_ADDRESS = Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc";
3130
}
3231

framework/src/test/java/org/tron/common/runtime/InternalTransactionComplexTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public class InternalTransactionComplexTest extends BaseTest {
2727
private static boolean init;
2828

2929
static {
30-
dbPath = "output_InternalTransactionComplexTest";
31-
Args.setParam(new String[]{"--output-directory", dbPath, "--debug", "--support-constant"},
30+
Args.setParam(new String[]{"--output-directory", dbPath(), "--debug", "--support-constant"},
3231
Constant.TEST_CONF);
3332
OWNER_ADDRESS = Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc";
3433
}

framework/src/test/java/org/tron/common/runtime/ProgramResultTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class ProgramResultTest extends BaseTest {
4444
private static boolean init;
4545

4646
static {
47-
dbPath = "output_InternalTransactionComplexTest";
48-
Args.setParam(new String[]{"--output-directory", dbPath, "--debug", "--support-constant"},
47+
Args.setParam(new String[]{"--output-directory", dbPath(), "--debug", "--support-constant"},
4948
Constant.TEST_CONF);
5049
OWNER_ADDRESS = Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc";
5150
TRANSFER_TO = Wallet.getAddressPreFixString() + "548794500882809695a8a687866e76d4271a1abc";

framework/src/test/java/org/tron/common/runtime/RuntimeImplTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public class RuntimeImplTest extends BaseTest {
4040
private final long creatorTotalBalance = 3_000_000_000L;
4141

4242
static {
43-
dbPath = "output_RuntimeImplTest";
44-
Args.setParam(new String[]{"--output-directory", dbPath, "--debug"}, Constant.TEST_CONF);
43+
Args.setParam(new String[]{"--output-directory", dbPath(), "--debug"}, Constant.TEST_CONF);
4544
callerAddress = Hex
4645
.decode(Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc");
4746
creatorAddress = Hex

0 commit comments

Comments
 (0)