We can't invoke equals method on object, that can be null, due it's lead to NPE

This commit is contained in:
vraskulin 2017-01-09 15:17:59 +03:00
parent 246469ee48
commit 51e5640c8e

View file

@ -3,6 +3,7 @@ package org.mage.plugins.card.utils;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.HashMap;
import java.util.Objects;
import java.util.prefs.Preferences;
import mage.client.MageFrame;
import mage.client.constants.Constants;
@ -120,8 +121,9 @@ public class CardImageUtils {
public static String getImageBasePath() {
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
String imagesPath = useDefault.equals("true") ? Constants.IO.imageBaseDir : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
if (!imagesPath.endsWith(TFile.separator)) {
String imagesPath = Objects.equals(useDefault, "true") ? Constants.IO.imageBaseDir : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
if (imagesPath != null && !imagesPath.endsWith(TFile.separator)) {
imagesPath += TFile.separator;
}
return imagesPath;
@ -161,7 +163,7 @@ public class CardImageUtils {
public static String generateImagePath(CardDownloadData card) {
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
String imagesPath = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
String imagesPath = Objects.equals(useDefault, "true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
String imageDir = getImageDir(card, imagesPath);
String imageName;
@ -189,7 +191,7 @@ public class CardImageUtils {
public static String generateTokenDescriptorImagePath(CardDownloadData card) {
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
String imagesPath = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
String imagesPath = Objects.equals(useDefault, "true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
String straightImageFile = getTokenDescriptorImagePath(card);
TFile file = new TFile(straightImageFile);