Skip to content

Commit 0e85e1a

Browse files
committed
Copy tracks to new list before modifying
1 parent 727df6a commit 0e85e1a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

player/src/main/java/xyz/gianlu/librespot/player/PagesLoader.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ boolean nextPage() throws IOException, MercuryClient.MercuryException {
137137
void putFirstPages(@NotNull List<ContextPage> pages, String contextUri) {
138138
if (currentPage != -1 || !this.pages.isEmpty()) throw new IllegalStateException();
139139
for (ContextPage page : pages) {
140-
sanitizeTracks(page.getTracksList(), contextUri == null ? null : PlayableId.inferUriPrefix(contextUri));
141-
this.pages.add(page);
140+
List<ContextTrack> tracks = new ArrayList<>(page.getTracksList());
141+
sanitizeTracks(tracks, contextUri == null ? null : PlayableId.inferUriPrefix(contextUri));
142+
this.pages.add(page.toBuilder().clearTracks().addAllTracks(tracks).build());
142143
}
143144
}
144145

0 commit comments

Comments
 (0)