Github user emilianbold commented on a diff in the pull request:
https://github.com/apache/incubator-netbeans/pull/23#discussion_r142003704
--- Diff:
db.sql.editor/test/unit/src/org/netbeans/modules/db/sql/editor/completion/SelectCompletionQueryTest.java
---
@@ -125,11 +125,11 @@ public void runTest() throws Exception {
public void testCompletion() throws Exception {
StringBuilder sqlData = new StringBuilder();
- List<String> modelData = new ArrayList<String>();
- BufferedReader reader = new BufferedReader(new
InputStreamReader(SelectCompletionQueryTest.class.getResource(getName() +
".test").openStream(), "utf-8"));
- try {
+ List<String> modelData = new ArrayList<>();
+ try (InputStream is =
SelectCompletionQueryTest.class.getResourceAsStream(getName() + ".test");
+ BufferedReader reader = new BufferedReader(new
InputStreamReader(is, "utf-8"))) {
boolean separatorRead = false;
- for (String line; (line = reader.readLine()) != null;) {
+ for (String line = reader.readLine(); line != null; line =
reader.readLine()) {
--- End diff --
I believe the canonical trick is to have
```java
String line;
while((line = reader.readLine()) != null) {
...
}
```
And the original `for` just mixed those to limit the scope of the `line`
variable to the `for` block... which is nice.
Your `for` repeats the `reader.readLine()` call which seems confusing.
---