Removing the SneakyThrow.java file in room-runtime.
Test: N/A
Bug: 242223919
Change-Id: If83f8a857ccc25ce90043c1438cb48bddbb522e6
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/AutoClosingRoomOpenHelperTest.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/AutoClosingRoomOpenHelperTest.java
index 3033b44..d4a92d7 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/AutoClosingRoomOpenHelperTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/AutoClosingRoomOpenHelperTest.java
@@ -35,7 +35,6 @@
import androidx.room.integration.testapp.TestDatabase;
import androidx.room.integration.testapp.dao.UserDao;
import androidx.room.integration.testapp.vo.User;
-import androidx.room.util.SneakyThrow;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.filters.MediumTest;
@@ -104,16 +103,12 @@
Thread.sleep(30);
mUserDao.load(1);
// Connection should be auto closed here
-
-
mDb.runInTransaction(
() -> {
try {
Thread.sleep(100);
- // Connection would've been auto closed here
- } catch (InterruptedException e) {
- SneakyThrow.reThrow(e);
- }
+ } catch (InterruptedException ignored) { }
+ // Connection would've been auto closed here
}
);
diff --git a/room/room-runtime/src/main/java/androidx/room/AutoCloser.kt b/room/room-runtime/src/main/java/androidx/room/AutoCloser.kt
index f79f982..456d2a9 100644
--- a/room/room-runtime/src/main/java/androidx/room/AutoCloser.kt
+++ b/room/room-runtime/src/main/java/androidx/room/AutoCloser.kt
@@ -20,7 +20,6 @@
import android.os.SystemClock
import androidx.annotation.GuardedBy
import androidx.annotation.VisibleForTesting
-import androidx.room.util.SneakyThrow
import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.SupportSQLiteOpenHelper
import java.io.IOException
@@ -92,11 +91,7 @@
delegateDatabase?.let {
if (it.isOpen) {
- try {
- it.close()
- } catch (e: IOException) {
- SneakyThrow.reThrow(e)
- }
+ it.close()
}
}
delegateDatabase = null
diff --git a/room/room-runtime/src/main/java/androidx/room/AutoClosingRoomOpenHelper.kt b/room/room-runtime/src/main/java/androidx/room/AutoClosingRoomOpenHelper.kt
index d32cf1d..76c4ba8 100644
--- a/room/room-runtime/src/main/java/androidx/room/AutoClosingRoomOpenHelper.kt
+++ b/room/room-runtime/src/main/java/androidx/room/AutoClosingRoomOpenHelper.kt
@@ -26,7 +26,6 @@
import android.os.CancellationSignal
import android.util.Pair
import androidx.annotation.RequiresApi
-import androidx.room.util.SneakyThrow
import androidx.sqlite.db.SupportSQLiteCompat
import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.SupportSQLiteOpenHelper
@@ -69,11 +68,7 @@
}
override fun close() {
- try {
- autoClosingDb.close()
- } catch (e: IOException) {
- SneakyThrow.reThrow(e)
- }
+ autoClosingDb.close()
}
/**
diff --git a/room/room-runtime/src/main/java/androidx/room/util/SneakyThrow.java b/room/room-runtime/src/main/java/androidx/room/util/SneakyThrow.java
deleted file mode 100644
index 76968ab..0000000
--- a/room/room-runtime/src/main/java/androidx/room/util/SneakyThrow.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.room.util;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-/**
- * Java 8 Sneaky Throw technique.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
-public class SneakyThrow {
-
- /**
- * Re-throws a checked exception as if it was a runtime exception without wrapping it.
- *
- * @param e the exception to re-throw.
- */
- public static void reThrow(@NonNull Exception e) {
- sneakyThrow(e);
- }
-
- @SuppressWarnings("unchecked")
- private static <E extends Throwable> void sneakyThrow(@NonNull Throwable e) throws E {
- throw (E) e;
- }
-
- private SneakyThrow() {
-
- }
-}