# HG changeset patch # User Alexander Simon # Date 1479724731 -10800 # Mon Nov 21 13:38:51 2016 +0300 # Branch release82 # Node ID 786dc9d45c0d9fdf454d4da8ff770bb8484321fa # Parent a35fd7b8f600e4e625ec3820398484f3616c410b work around Bug 269032 - Launchers can not be modified through dialog - do not use bogus FileObject.asLines() method diff --git a/cnd.makeproject.ui/src/org/netbeans/modules/cnd/makeproject/ui/launchers/actions/LaunchersConfig.java b/cnd.makeproject.ui/src/org/netbeans/modules/cnd/makeproject/ui/launchers/actions/LaunchersConfig.java --- a/cnd.makeproject.ui/src/org/netbeans/modules/cnd/makeproject/ui/launchers/actions/LaunchersConfig.java +++ b/cnd.makeproject.ui/src/org/netbeans/modules/cnd/makeproject/ui/launchers/actions/LaunchersConfig.java @@ -41,11 +41,12 @@ */ package org.netbeans.modules.cnd.makeproject.ui.launchers.actions; +import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; +import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; @@ -107,6 +108,7 @@ } private void load(FileObject config, boolean pub) { + BufferedReader in = null; try { int id = pub ? COMMON_PUBLIC_INDEX : COMMON_PRIVATE_INDEX; LauncherConfig l = map.get(id); @@ -114,11 +116,10 @@ l = new LauncherConfig(id, pub); map.put(id, l); } - List asLines = new ArrayList<>(config.asLines("UTF-8")); //NOI18N - Iterator it = asLines.iterator(); boolean initComments = true; - while (it.hasNext()) { - String line = it.next(); + in = new BufferedReader(new InputStreamReader(config.getInputStream(), "UTF-8")); //NOI18N + String line; + while((line = in.readLine()) != null) { int i = line.indexOf('#'); if (i >= 0) { if (i == 0) { @@ -138,10 +139,16 @@ if (line.isEmpty()) { continue; } - while (it.hasNext() && line.endsWith("\\")) { //NOI18N - String next = it.next(); - next = next.replace('\t', ' '); - line = line.substring(0, line.length() - 1) + next; + boolean eof = false; + while (line.endsWith("\\") && !eof) { //NOI18N + String next = in.readLine(); + if (next == null) { + eof = true; + line = line.substring(0, line.length() - 1); + } else { + next = next.replace('\t', ' '); + line = line.substring(0, line.length() - 1) + next; + } } i = line.indexOf('='); if (i > 0) { @@ -150,10 +157,19 @@ add(key, value, pub); } + if (eof) { + break; + } } - } catch (IOException ex) { ex.printStackTrace(System.err); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ex) { + } + } } }