From f9e4fbc9b348fe09a12755686be57ca00db0f936 Mon Sep 17 00:00:00 2001 From: Siphonight Date: Mon, 16 Nov 2026 01:29:16 +0100 Subject: [PATCH] Fix du fix : try-with-resources sur variable Java 9+ interdit en source 8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le commit précédent (garde null files.lsd) ne compilait pas (BUILD FAILED 540ms — try(reader) Java 9+ sur un module source 8) et avait quand même été poussé + re-taggé ; lecture manuelle + finally à la place. --- .../dethsquare/util/AndroidIOUtils.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dethsquare/android/src/main/java/com/ezardlabs/dethsquare/util/AndroidIOUtils.java b/dethsquare/android/src/main/java/com/ezardlabs/dethsquare/util/AndroidIOUtils.java index c451525..4f93ed1 100644 --- a/dethsquare/android/src/main/java/com/ezardlabs/dethsquare/util/AndroidIOUtils.java +++ b/dethsquare/android/src/main/java/com/ezardlabs/dethsquare/util/AndroidIOUtils.java @@ -84,13 +84,14 @@ public class AndroidIOUtils implements IOUtils { + "sans indexResources ?)"); return new String[0]; } - try (reader) { - ArrayList list = new ArrayList<>(); + // Pas de try-with-resources sur la variable (source 8 du dépôt) : + // fermeture manuelle garanties par le finally. + ArrayList list = new ArrayList<>(); + try { String temp; while ((temp = reader.readLine()) != null) { list.add(temp); } - return list.toArray(new String[list.size()]); } catch (IOException e) { // POURQUOI error (et pas err+printStackTrace) : files.lsd est // l'INDEX de toutes les ressources — s'il manque, TOUTES les @@ -98,8 +99,15 @@ public class AndroidIOUtils implements IOUtils { // prefabs introuvables). La stack va dans le tampon GameLog. GameLog.e("LS-INIT", "index files.lsd de '" + dirPath + "' illisible — " + "aucune ressource énumérable (généré par la tâche Gradle indexResources)", e); - return new String[0]; + } finally { + try { + reader.close(); + } catch (IOException ignored) { + // Le close d'un reader déjà cassé n'est pas une erreur de + // jeu — on garde le retour partiel. + } } + return list.toArray(new String[list.size()]); } public BufferedReader getReader(String path) {