[Android] Prevent NullPointerException by avoiding race conditions

Nicolas Pomepuy git at videolan.org
Tue Oct 5 08:11:19 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Oct  1 09:29:00 2021 +0200| [65cac21c985220222d1ee67934a9fea72ea90ca1] | committer: Nicolas Pomepuy

Prevent NullPointerException by avoiding race conditions

> https://code.videolan.org/videolan/vlc-android/commit/65cac21c985220222d1ee67934a9fea72ea90ca1
---

 .../videolan/medialibrary/interfaces/media/MediaWrapper.java   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/media/MediaWrapper.java b/medialibrary/src/org/videolan/medialibrary/interfaces/media/MediaWrapper.java
index a9c9f04fd..a4558b13d 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/media/MediaWrapper.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/media/MediaWrapper.java
@@ -535,10 +535,12 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
 
     @Override
     public String getTitle() {
-        if (!TextUtils.isEmpty(mDisplayTitle))
-            return mDisplayTitle;
-        if (!TextUtils.isEmpty(mTitle))
-            return mTitle;
+        String displayTitle = mDisplayTitle;
+        if (!TextUtils.isEmpty(displayTitle))
+            return displayTitle;
+        String title = mTitle;
+        if (!TextUtils.isEmpty(title))
+            return title;
         String fileName = getFileName();
         if (fileName == null)
             return "";



More information about the Android mailing list