Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JVM synchronization issue #4218

Merged
merged 5 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jni/java/wallet/core/java/GenericPhantomReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import java.lang.ref.ReferenceQueue;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;

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

private static final Set<GenericPhantomReference> references = new HashSet<>();
private static final Set<GenericPhantomReference> references = Collections.synchronizedSet(new HashSet<>());
private static final ReferenceQueue<Object> queue = new ReferenceQueue<>();

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.trustwallet.core

import java.lang.ref.PhantomReference
import java.lang.ref.ReferenceQueue
import java.util.Collections

internal class GenericPhantomReference private constructor(
referent: Any,
Expand All @@ -10,7 +11,7 @@ internal class GenericPhantomReference private constructor(
) : PhantomReference<Any>(referent, queue) {

companion object {
private val references: MutableSet<GenericPhantomReference> = HashSet()
private val references: MutableSet<GenericPhantomReference> = Collections.synchronizedSet(HashSet())
private val queue: ReferenceQueue<Any> = ReferenceQueue()

init {
Expand Down
2 changes: 1 addition & 1 deletion rust/chains/tw_solana/src/transaction/versioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<'de> Deserialize<'de> for MessagePrefix {
{
struct PrefixVisitor;

impl<'de> Visitor<'de> for PrefixVisitor {
impl Visitor<'_> for PrefixVisitor {
type Value = MessagePrefix;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion rust/frameworks/tw_ton_sdk/src/boc/binary_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl BinaryWriter {
} else {
self.write_bytes(&data[..data_len - 1])?;
let last_byte = data[data_len - 1];
let l = last_byte | 1 << (8 - rest_bits - 1);
let l = last_byte | (1 << (8 - rest_bits - 1));
self.write(8, l)?;
}

Expand Down
2 changes: 1 addition & 1 deletion rust/frameworks/tw_ton_sdk/src/boc/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ fn write_raw_cell(
if !full_bytes {
writer.write_bytes(&data[..data_len_bytes - 1])?;
let last_byte = data[data_len_bytes - 1];
let l = last_byte | 1 << (8 - padding_bits - 1);
let l = last_byte | (1 << (8 - padding_bits - 1));
writer.write(8, l)?;
} else {
writer.write_bytes(data)?;
Expand Down
4 changes: 1 addition & 3 deletions rust/tw_any_coin/src/wallet_connect_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ impl WalletConnectRequest {
#[inline]
pub fn parse(coin: CoinType, input: &[u8]) -> SigningResult<Data> {
let (ctx, entry) = coin_dispatcher(coin)?;
entry
.wallet_connect_parse_request(&ctx, input)
.map_err(SigningError::from)
entry.wallet_connect_parse_request(&ctx, input)
}
}
2 changes: 1 addition & 1 deletion rust/tw_encoding/src/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub trait DecodeHex {
fn decode_hex(&self) -> FromHexResult<Data>;
}

impl<'a> DecodeHex for &'a str {
impl DecodeHex for &str {
fn decode_hex(&self) -> FromHexResult<Data> {
decode(self)
}
Expand Down
2 changes: 1 addition & 1 deletion rust/tw_evm/src/message/eip712/message_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct CustomTypeBuilder<'a> {
type_properties: &'a mut Vec<Property>,
}

impl<'a> CustomTypeBuilder<'a> {
impl CustomTypeBuilder<'_> {
pub fn add_property(&mut self, name: &str, property_type: PropertyType) -> &mut Self {
self.type_properties.push(Property {
name: name.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions rust/tw_misc/src/test_utils/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl ToJson for Json {
}
}

impl<'a> ToJson for Cow<'a, str> {
impl ToJson for Cow<'_, str> {
#[track_caller]
fn to_json(&self) -> Json {
self.as_ref().to_json()
Expand All @@ -30,7 +30,7 @@ impl ToJson for String {
}
}

impl<'a> ToJson for &'a str {
impl ToJson for &str {
#[track_caller]
fn to_json(&self) -> Json {
serde_json::from_str(self).expect("Error on deserializing JSON from string")
Expand Down
2 changes: 1 addition & 1 deletion tools/install-rust-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

NIGHTLY="nightly-2024-06-13"
NIGHTLY="nightly-2025-01-16"

rustup toolchain install $NIGHTLY
rustup default $NIGHTLY
Expand Down
Loading