- edited description
NullPointerException when committing changes
I'd like to report an occasional issue I have when executing [AudioFile].commit() method on Android devices. The report comes from Analytics so I couldn't reproduce it. If you need more information, please let me know, thanks.
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference at
org.jaudiotagger.audio.generic.AudioFileWriter.delete(SourceFile:200) at
org.jaudiotagger.audio.generic.AudioFileWriter.precheckWrite(SourceFile:275) at
org.jaudiotagger.audio.generic.AudioFileWriter.write(SourceFile:317) at
org.jaudiotagger.audio.AudioFileIO.writeFile(SourceFile:482) at
org.jaudiotagger.audio.AudioFileIO.write(SourceFile:208) at
org.jaudiotagger.audio.AudioFile.commit(SourceFile:124)
Comments (14)
-
reporter -
repo owner I would guess that the problem is your calling code is sometimes pass a null value ?
-
reporter Commit method takes no parameters. If you mean in tag fields that's not possible since I'm explicitly checking for nulls before using setField method.
-
repo owner Can we see your calling code ?
-
reporter This is the only method through I set fields.
public void setField(FieldKey key, String value) { if (value != null && !value.equalsIgnoreCase(FrameBodyCOMM.DEFAULT)) { if ((key == FieldKey.TRACK || key == FieldKey.TRACK_TOTAL || key == FieldKey.DISC_NO || key == FieldKey.DISC_TOTAL) && (value.equalsIgnoreCase(FrameBodyCOMM.DEFAULT) || value.equalsIgnoreCase("null"))) { value = "0"; } for (Tag tag : this.audioFileList.values()) { try { tag.setField(key, value); } catch (FieldDataInvalidException exception) { exception.printStackTrace(); } } } }
-
repo owner This isnt the code that calls the commit,the error loooks like the underlying filename of the audio file is null rather than the fields being null
-
reporter I just use this line for reading and it's inside a try catch so any error related to the file should be caught such as InvalidAudioFrameException.
AudioFile audio = AudioFileIO.read(new File(path));
Regarding the commit, I'm just calling it as described in documentation
for (final AudioFile audioFile : this.audioFileList.keySet()) { audioFile.commit(); }
-
reporter I forgot to mention that I'm using 2.2.6 snapshot source, edited so it uses java.noi.Charset instead of java.noi.StandardCharsets
-
repo owner I dont use Android and dont understand this virtual method error I think the best thing would be to post this question on stackoverflow to make progress with this.
-
reporter I'll try and eventually will post here the replies.
-
repo owner - changed status to invalid
Assume must be an error in usercode
-
reporter getAbsolutePath() is just the Android equivalent of getPath() and it is being executed inside AudioFileWriter.delete() when doing [AudioFile].getFile().getPath() but for some reason getFile() returns null. I don't see how calling just commit() should be an error in user code.
-
repo owner Well we can argue about that but the point is I dont know what is causing the issue, therefore I cant currentiy fix it
-
reporter Ok then, I'll try to add some logging in next app releases so I'll see if I can find some clue with it
- Log in to comment