Skip to content

Commit 8b2cdb7

Browse files
Fix JVM synchronization issue (#4218)
* Fix Java JVM leak * clean * apply to jni * [Misc]: Upgrade Rust toolchain to `nightly-2025-01-16` * [Misc]: Fix Clippy warnings --------- Co-authored-by: Satoshi Otomakan <[email protected]>
1 parent dee25d4 commit 8b2cdb7

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

jni/java/wallet/core/java/GenericPhantomReference.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
import java.lang.ref.ReferenceQueue;
55
import java.util.Set;
66
import java.util.HashSet;
7+
import java.util.Collections;
78

89
public class GenericPhantomReference extends PhantomReference<Object> {
910
private final long nativeHandle;
1011
private final OnDeleteCallback onDeleteCallback;
1112

12-
private static final Set<GenericPhantomReference> references = new HashSet<>();
13+
private static final Set<GenericPhantomReference> references = Collections.synchronizedSet(new HashSet<>());
1314
private static final ReferenceQueue<Object> queue = new ReferenceQueue<>();
1415

1516
static {

kotlin/wallet-core-kotlin/src/commonAndroidJvmMain/kotlin/com/trustwallet/core/GenericPhantomReference.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.trustwallet.core
22

33
import java.lang.ref.PhantomReference
44
import java.lang.ref.ReferenceQueue
5+
import java.util.Collections
56

67
internal class GenericPhantomReference private constructor(
78
referent: Any,
@@ -10,7 +11,7 @@ internal class GenericPhantomReference private constructor(
1011
) : PhantomReference<Any>(referent, queue) {
1112

1213
companion object {
13-
private val references: MutableSet<GenericPhantomReference> = HashSet()
14+
private val references: MutableSet<GenericPhantomReference> = Collections.synchronizedSet(HashSet())
1415
private val queue: ReferenceQueue<Any> = ReferenceQueue()
1516

1617
init {

rust/chains/tw_solana/src/transaction/versioned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'de> Deserialize<'de> for MessagePrefix {
189189
{
190190
struct PrefixVisitor;
191191

192-
impl<'de> Visitor<'de> for PrefixVisitor {
192+
impl Visitor<'_> for PrefixVisitor {
193193
type Value = MessagePrefix;
194194

195195
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {

rust/frameworks/tw_ton_sdk/src/boc/binary_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl BinaryWriter {
5454
} else {
5555
self.write_bytes(&data[..data_len - 1])?;
5656
let last_byte = data[data_len - 1];
57-
let l = last_byte | 1 << (8 - rest_bits - 1);
57+
let l = last_byte | (1 << (8 - rest_bits - 1));
5858
self.write(8, l)?;
5959
}
6060

rust/frameworks/tw_ton_sdk/src/boc/raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fn write_raw_cell(
263263
if !full_bytes {
264264
writer.write_bytes(&data[..data_len_bytes - 1])?;
265265
let last_byte = data[data_len_bytes - 1];
266-
let l = last_byte | 1 << (8 - padding_bits - 1);
266+
let l = last_byte | (1 << (8 - padding_bits - 1));
267267
writer.write(8, l)?;
268268
} else {
269269
writer.write_bytes(data)?;

rust/tw_any_coin/src/wallet_connect_request.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ impl WalletConnectRequest {
1616
#[inline]
1717
pub fn parse(coin: CoinType, input: &[u8]) -> SigningResult<Data> {
1818
let (ctx, entry) = coin_dispatcher(coin)?;
19-
entry
20-
.wallet_connect_parse_request(&ctx, input)
21-
.map_err(SigningError::from)
19+
entry.wallet_connect_parse_request(&ctx, input)
2220
}
2321
}

rust/tw_encoding/src/hex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub trait DecodeHex {
3030
fn decode_hex(&self) -> FromHexResult<Data>;
3131
}
3232

33-
impl<'a> DecodeHex for &'a str {
33+
impl DecodeHex for &str {
3434
fn decode_hex(&self) -> FromHexResult<Data> {
3535
decode(self)
3636
}

rust/tw_evm/src/message/eip712/message_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct CustomTypeBuilder<'a> {
3838
type_properties: &'a mut Vec<Property>,
3939
}
4040

41-
impl<'a> CustomTypeBuilder<'a> {
41+
impl CustomTypeBuilder<'_> {
4242
pub fn add_property(&mut self, name: &str, property_type: PropertyType) -> &mut Self {
4343
self.type_properties.push(Property {
4444
name: name.to_string(),

rust/tw_misc/src/test_utils/json.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl ToJson for Json {
1616
}
1717
}
1818

19-
impl<'a> ToJson for Cow<'a, str> {
19+
impl ToJson for Cow<'_, str> {
2020
#[track_caller]
2121
fn to_json(&self) -> Json {
2222
self.as_ref().to_json()
@@ -30,7 +30,7 @@ impl ToJson for String {
3030
}
3131
}
3232

33-
impl<'a> ToJson for &'a str {
33+
impl ToJson for &str {
3434
#[track_caller]
3535
fn to_json(&self) -> Json {
3636
serde_json::from_str(self).expect("Error on deserializing JSON from string")

tools/install-rust-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
NIGHTLY="nightly-2024-06-13"
5+
NIGHTLY="nightly-2025-01-16"
66

77
rustup toolchain install $NIGHTLY
88
rustup default $NIGHTLY

0 commit comments

Comments
 (0)