Page 1 of 1

patch: avoid nullpointer in musicFile

PostPosted: Sat Jul 30, 2011 12:16 am
by ioggstream
the following patch ensures getSuffix() is always != null
Code: Select all
--- src/main/java/net/sourceforge/subsonic/domain/MusicFile.java        (revision 2349)
+++ src/main/java/net/sourceforge/subsonic/domain/MusicFile.java        (working copy)

@@ -219,7 +264,7 @@
      * @return The file suffix.
      */
     public String getSuffix() {
-        return StringUtils.getFilenameExtension(getName());
+        return FilenameUtils.getExtension(getName());
     }

     /**


and let us save one more line :)

Code: Select all

--- src/main/java/net/sourceforge/subsonic/service/metadata/JaudiotaggerParser.java     (revision 2349)
+++ src/main/java/net/sourceforge/subsonic/service/metadata/JaudiotaggerParser.java     (working copy)

@@ -226,7 +255,7 @@
             return false;
         }

-        String extension = FilenameUtils.getExtension(file.getName()).toLowerCase();
+        String extension = file.getSuffix();

         return extension.equals("mp3") ||
                extension.equals("m4a") ||