Skip to content

Commit

Permalink
review and refactor according to github security scans
Browse files Browse the repository at this point in the history
Signed-off-by: neo <[email protected]>
  • Loading branch information
neowu committed Nov 8, 2024
1 parent b6e0a1b commit 8cd7188
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
40 changes: 21 additions & 19 deletions core-ng/src/main/java/core/framework/http/EventSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,7 @@ public void close() {

@Override
public Iterator<Event> iterator() {
return new Iterator<>() {
@Override
public boolean hasNext() {
if (nextEvent != null) return true;
nextEvent = parseResponse(body.source());
return nextEvent != null;
}

@Override
public Event next() {
if (nextEvent != null || hasNext()) {
var event = nextEvent;
nextEvent = null;
return event;
} else {
throw new NoSuchElementException();
}
}
};
return new EventIterator();
}

private Event parseResponse(BufferedSource source) {
Expand Down Expand Up @@ -103,4 +85,24 @@ private Event parseResponse(BufferedSource source) {

public record Event(String id, String data) {
}

private class EventIterator implements Iterator<Event> {
@Override
public boolean hasNext() {
if (nextEvent != null) return true;
nextEvent = parseResponse(body.source());
return nextEvent != null;
}

@Override
public Event next() {
if (nextEvent != null || hasNext()) {
var event = nextEvent;
nextEvent = null;
return event;
} else {
throw new NoSuchElementException();
}
}
}
}
2 changes: 1 addition & 1 deletion core-ng/src/main/java/core/framework/util/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static byte[] bytes(Path file) {
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
LOGGER.debug("bytes, file={}, elapsed={}", file.toString(), watch.elapsed());
LOGGER.debug("bytes, file={}, elapsed={}", file, watch.elapsed());
}
}

Expand Down

0 comments on commit 8cd7188

Please sign in to comment.