no need to catch an exception, only to throw it

Just let the SecurityException be throwing where it originated.

From PMD: "A catch statement that catches an exception only to wrap it
in a new instance of the same type of exception and throw it should be
avoided".

This cleans up a little from !482.  Ctrl-Alt-L and Ctrl-Alt-O before
committing! :-)
This commit is contained in:
Hans-Christoph Steiner 2017-04-18 21:07:16 +02:00
parent 432f45254b
commit 06dff8184b
2 changed files with 1 additions and 7 deletions

View File

@ -5,9 +5,8 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;
import org.fdroid.fdroid.installer.PrivilegedInstaller;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.installer.PrivilegedInstaller;
public class PackageManagerCompat {
@ -29,8 +28,6 @@ public class PackageManagerCompat {
mPm.setInstallerPackageName(packageName, "org.fdroid.fdroid");
}
Utils.debugLog(TAG, "Installer package name for " + packageName + " set successfully");
} catch (SecurityException e) {
throw new SecurityException(e);
} catch (Exception e) {
// Many problems can occur:
// * App wasn't installed due to incompatibility

View File

@ -31,11 +31,8 @@ import android.os.Build;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.compat.PackageManagerCompat;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.privileged.IPrivilegedCallback;
import org.fdroid.fdroid.privileged.IPrivilegedService;