File tree Expand file tree Collapse file tree
main/kotlin/com/almasb/fxgl/app/services
test/kotlin/com/almasb/fxgl/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -533,7 +533,7 @@ class FXGLAssetLoaderService : AssetLoaderService() {
533533 cachedAssets[cacheKey] = loaded as Any
534534 }
535535
536- loaded
536+ data.cast( loaded as Any )
537537 } catch (e: Exception ) {
538538 log.warning(" Failed to load ${loadParams.url} " , e)
539539 data.getDummy()
@@ -696,6 +696,12 @@ private class TextAssetLoader : AssetLoader<List<*>>(
696696 List : :class.java,
697697 TEXT_DIR
698698) {
699+ override fun cast (obj : Any ): List <String > {
700+ val list = obj as List <String >
701+
702+ return list.toList()
703+ }
704+
699705 override fun load (url : URL ): List <String > = url.openStream().bufferedReader().readLines()
700706
701707 override fun getDummy (): List <String > = emptyList()
Original file line number Diff line number Diff line change @@ -185,7 +185,8 @@ class AssetLoaderServiceTest {
185185
186186 assertThat(lines.size, `is `(0 ))
187187
188- assertTrue(assetLoader.loadText(" test1.txt" ) == = assetLoader.loadText(" test1.txt" ))
188+ // ensure a new copy of the list is loaded so that original cannot be modified
189+ assertTrue(assetLoader.loadText(" test1.txt" ) != = assetLoader.loadText(" test1.txt" ))
189190 }
190191
191192 @Test
You can’t perform that action at this time.
0 commit comments