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

Switch order of literals to prevent NullPointerException #12832

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/androidTest/java/com/owncloud/android/AbstractIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public static void beforeAll() {
String darkModeParameter = arguments.getString("DARKMODE");

if (darkModeParameter != null) {
if (darkModeParameter.equalsIgnoreCase("dark")) {
if ("dark".equalsIgnoreCase(darkModeParameter)) {
DARK_MODE = "dark";
AppPreferencesImpl.fromContext(targetContext).setDarkThemeMode(DarkMode.DARK);
MainApp.setAppTheme(DarkMode.DARK);
Expand All @@ -187,7 +187,7 @@ public static void beforeAll() {
}
}

if (DARK_MODE.equalsIgnoreCase("light") && COLOR.equalsIgnoreCase("blue")) {
if ("light".equalsIgnoreCase(DARK_MODE) && "blue".equalsIgnoreCase(COLOR)) {
// use already existing names
DARK_MODE = "";
COLOR = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public void testMetadata() throws IOException, AccountUtils.AccountNotFoundExcep

OCFile ocFile = null;
for (OCFile f : files) {
if (f.getFileName().equals("metadata.jpg")) {
if ("metadata.jpg".equals(f.getFileName())) {
ocFile = f;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
try {
String publicKey = EncryptionUtils.getPublicKey(user, shareeName, arbitraryDataProvider);

if (publicKey.equals("")) {
if ("".equals(publicKey)) {
NextcloudClient nextcloudClient = new ClientFactoryImpl(context).createNextcloudClient(user);
RemoteOperationResult<String> result = new GetPublicKeyRemoteOperation(shareeName).execute(nextcloudClient);
if (result.isSuccess()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public URLConnection getConnection() throws IOException {
String protocol = mUrl.getProtocol();
String userPass = mUsername + ":" + mPassword;

if (protocol.equalsIgnoreCase("ftp") || protocol.equalsIgnoreCase("ftps")) {
if ("ftp".equalsIgnoreCase(protocol) || "ftps".equalsIgnoreCase(protocol)) {
String external = mUrl.toExternalForm();
String end = external.substring(protocol.length() + HTTP_SEP.length());
return new URL(protocol + HTTP_SEP + userPass + "@" + end).openConnection();
}

if (protocol.equalsIgnoreCase("http") || protocol.equalsIgnoreCase("https")) {
if ("http".equalsIgnoreCase(protocol) || "https".equalsIgnoreCase(protocol)) {
String encoded = new String(new Base64().encode(userPass.getBytes("UTF-8")));
URLConnection connection = mUrl.openConnection();
connection.setRequestProperty("Authorization", "Basic " + encoded);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ private void checkTestValue(VEvent e, ContentValues c, String keyValue, String t
String expected = parts.length > 1 ? parts[1] : "";
String got = c.getAsString(key);

if (expected.equals("<non-null>") && got != null) {
if ("<non-null>".equals(expected) && got != null) {
got = "<non-null>"; // Sentinel for testing present and non-null
}
if (got == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ private boolean isUtcTimeZone(final String tz) {
return true;
}
final String utz = tz.toUpperCase(Locale.US);
return utz.equals("UTC") || utz.equals("UTC-0") || utz.equals("UTC+0") || utz.endsWith("/UTC");
return "UTC".equals(utz) || "UTC-0".equals(utz) || "UTC+0".equals(utz) || utz.endsWith("/UTC");
}

private Date getDateTime(Cursor cur, String dbName, String dbTzName, Calendar cal) {
Expand Down