File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
main/kotlin/com/almasb/fxgl/app/services
test/kotlin/com/almasb/fxgl/app Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -533,7 +533,7 @@ class FXGLAssetLoaderService : AssetLoaderService() {
533
533
cachedAssets[cacheKey] = loaded as Any
534
534
}
535
535
536
- loaded
536
+ data.cast( loaded as Any )
537
537
} catch (e: Exception ) {
538
538
log.warning(" Failed to load ${loadParams.url} " , e)
539
539
data.getDummy()
@@ -696,6 +696,12 @@ private class TextAssetLoader : AssetLoader<List<*>>(
696
696
List : :class.java,
697
697
TEXT_DIR
698
698
) {
699
+ override fun cast (obj : Any ): List <String > {
700
+ val list = obj as List <String >
701
+
702
+ return list.toList()
703
+ }
704
+
699
705
override fun load (url : URL ): List <String > = url.openStream().bufferedReader().readLines()
700
706
701
707
override fun getDummy (): List <String > = emptyList()
Original file line number Diff line number Diff line change @@ -185,7 +185,8 @@ class AssetLoaderServiceTest {
185
185
186
186
assertThat(lines.size, `is `(0 ))
187
187
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" ))
189
190
}
190
191
191
192
@Test
You can’t perform that action at this time.
0 commit comments