Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: MediaFile::getDuration causing NPE #666

Open
adjokic opened this issue Jan 14, 2025 · 1 comment
Open

[Bug]: MediaFile::getDuration causing NPE #666

adjokic opened this issue Jan 14, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@adjokic
Copy link

adjokic commented Jan 14, 2025

What happened?

When auto-importing a playlist, I get a NullPointerException at PlaylistService.java:175:

        playlist.setDuration(files.stream().mapToDouble(MediaFile::getDuration).sum());

The quickest fix is to filter out nulls and map those to 0.

Steps to reproduce

  1. Create a playlist that references a MediaFile with an invalid header/null Duration value

Version

11.1.4 (Stable)

Version Detail

No response

Operating System

Linux (Dockerized)

Java Version

17.0.13+11-alpine-r0

Database

PostgreSQL 14.x

DB Detail

No response

Configuration paramter

JAVA_OPTS=-Dserver.use-forward-headers=true

Proxy Server

No response

client detail

No response

language

None

Relevant log output

2025-01-14 06:46:55.867  WARN --- o.a.p.service.PlaylistService            : Failed to auto-import playlist /playlists/Mine.m3u

java.lang.NullPointerException: null
	at java.base/java.util.stream.ReferencePipeline$6$1.accept(ReferencePipeline.java:248) ~[na:na]
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
	at java.base/java.util.stream.DoublePipeline.collect(DoublePipeline.java:541) ~[na:na]
	at java.base/java.util.stream.DoublePipeline.sum(DoublePipeline.java:450) ~[na:na]
	at org.airsonic.player.service.PlaylistService.setFilesInPlaylist(PlaylistService.java:175) ~[!/:11.1.4]
	at org.airsonic.player.service.PlaylistService.lambda$11(PlaylistService.java:162) ~[!/:11.1.4]
	at java.base/java.util.Optional.map(Optional.java:260) ~[na:na]
	at org.airsonic.player.service.PlaylistService.setFilesInPlaylist_aroundBody4(PlaylistService.java:161) ~[!/:11.1.4]
	at org.airsonic.player.service.PlaylistService$AjcClosure5.run(PlaylistService.java:1) ~[!/:11.1.4]
	at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed(AbstractTransactionAspect.aj:67) ~[spring-aspects-6.1.12.jar!/:6.1.12]
	at org.springframework.transaction.aspectj.AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation(AbstractTransactionAspect.aj:73) ~[spring-aspects-6.1.12.jar!/:6.1.12]
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:379) ~[spring-tx-6.1.12.jar!/:6.1.12]
	at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:71) ~[spring-aspects-6.1.12.jar!/:6.1.12]
@adjokic adjokic added the bug Something isn't working label Jan 14, 2025
@adjokic
Copy link
Author

adjokic commented Jan 14, 2025

I just realized that this was because of the playlist pointing to an invalid mp3. I will leave it up for discussion if this case should be handled more gracefully or to keep the behavior as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant