Skip to content

Commit 5dd424e

Browse files
Solving new code smell
1 parent 3e4a7b9 commit 5dd424e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/java/edu/ie3/datamodel/io/connectors/SqlConnector.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ public Iterator<Map<String, String>> getSqlIterator(ResultSet rs) {
162162
@Override
163163
public boolean hasNext() {
164164
try {
165-
boolean notEmpty = rs.isBeforeFirst() || rs.getRow() > 0;
166-
boolean notLastRow = !rs.isLast();
167-
return notEmpty && notLastRow;
165+
return rs.next();
168166
} catch (SQLException e) {
169167
log.error("Exception at extracting next ResultSet: ", e);
170168
closeResultSet(null, rs);
@@ -175,9 +173,9 @@ public boolean hasNext() {
175173
@Override
176174
public Map<String, String> next() {
177175
try {
178-
boolean valid = rs.next();
176+
boolean isEmpty = !rs.isBeforeFirst() && rs.getRow() == 0;
179177

180-
if (!valid)
178+
if (isEmpty || rs.isAfterLast())
181179
throw new NoSuchElementException(
182180
"There is no more element to iterate to in the ResultSet.");
183181

0 commit comments

Comments
 (0)