From ceb68b9787fe965b8315b8644968afc986cc8257 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 11 Feb 2019 07:32:17 -0800 Subject: [PATCH] Fix NPE when url for delete game has changed I think it's only an issue for debug builds where I've manually pointed at a different server, but just in case. --- .../app/src/main/java/org/eehouse/android/xw4/NetUtils.java | 5 ++++- .../app/src/main/java/org/eehouse/android/xw4/XWPrefs.java | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetUtils.java index ea1ac0cd6..f79df6abb 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetUtils.java @@ -251,7 +251,7 @@ public class NetUtils { params.put( k_PARAMS, param ); String paramsString = getPostDataString( params ); - if ( null != paramsString ) { + if ( null != conn && null != paramsString ) { try { conn.setReadTimeout( 15000 ); conn.setConnectTimeout( 15000 ); @@ -294,6 +294,9 @@ public class NetUtils { } catch( java.io.IOException ioe ) { Log.ex( TAG, ioe ); } + } else { + Log.e( TAG, "not running conn %s with params %s", conn, + paramsString ); } return result; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java index 6011a22b7..1f1a1a2eb 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java @@ -126,7 +126,11 @@ public class XWPrefs { public static String getDefaultRelayUrl( Context context ) { - return getPrefsString( context, R.string.key_relay_url ); + String result = getPrefsString( context, R.string.key_relay_url ); + if ( result == null || 0 == result.length() ) { + result = context.getString( R.string.default_relay_url ); + } + return result; } public static boolean getSkipToWebAPI( Context context )