Commit 53115eb4 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

Revert "Add finalizers to Web Payment Java objects that own native objects"

This reverts commit 379dbfae.

Reason for revert: Finalizers are banned in Chromium. These
finalizers have been causing assertion failures due to being
called on the background thread.

Bug: 1129695

Original change's description:
> Add finalizers to Web Payment Java objects that own native objects
> 
> These C++ objects are destroyed in PaymentRequestImpl.closeUIAndDestroyNativeObjects().
> However, if an object is garbage-collected for any reason without
> PaymentRequestImpl.closeUIAndDestroyNativeObjects() being called,
> then it will cause a memory leak.
> 
> A finalize method should be added to these objects to ensure destruction
> of the owned C++ objects.
> 
> Bug: 1090918
> Change-Id: I12df86f9705d81d630b63223d15354d2b022e888
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392290
> Commit-Queue: DongJun Kim <djmix.kim@samsung.com>
> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#804820}

TBR=rouslan@chromium.org,djmix.kim@samsung.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1090918
Change-Id: I7710d7065a7e225be3a331b0dec289506ee1d4c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422238Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808909}
parent 3949c89f
......@@ -46,16 +46,6 @@ public class CurrencyFormatter {
}
}
/**
* Destroys native object if owned object is not destroyed.
*
* @see java.lang.Object#finalize()
*/
@Override
public void finalize() throws Throwable {
destroy();
}
/** @return The currency code formatted for display. */
public String getFormattedCurrencyCode() {
return CurrencyFormatterJni.get().getFormattedCurrencyCode(
......
......@@ -42,16 +42,6 @@ public class JourneyLogger {
}
}
/**
* Destroys native object if owned object is not destroyed.
*
* @see java.lang.Object#finalize()
*/
@Override
public void finalize() throws Throwable {
destroy();
}
/**
* Sets the number of suggestions shown for the specified section.
*
......
......@@ -153,17 +153,7 @@ public class PaymentDetailsUpdateServiceHelper {
*/
public void reset() {
ThreadUtils.assertOnUiThread();
if (sInstance != null) sInstance = null;
}
/**
* Resets singleton instance if it is not destroyed.
*
* @see java.lang.Object#finalize()
*/
@Override
public void finalize() throws Throwable {
reset();
sInstance = null;
}
/**
......
......@@ -73,21 +73,9 @@ public class PaymentHandlerHost {
/** Destroys the native bridge. This object shouldn't be used afterwards. */
public void destroy() {
if (mNativePointer != 0) {
PaymentHandlerHostJni.get().destroy(mNativePointer);
mNativePointer = 0;
}
}
/**
* Destroys native object if owned object is not destroyed.
*
* @see java.lang.Object#finalize()
*/
@Override
public void finalize() throws Throwable {
destroy();
}
/**
* The interface implemented by the automatically generated JNI bindings class
......
......@@ -222,16 +222,6 @@ public class PaymentRequestSpec {
mNativePointer = 0;
}
/**
* Destroys native object if owned object is not destroyed.
*
* @see java.lang.Object#finalize()
*/
@Override
public void finalize() throws Throwable {
destroy();
}
@CalledByNative
private long getNativePointer() {
return mNativePointer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment