Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-40762] Cache encoded timestamp note in TimestampNotesOutputStream #20

merged 1 commit into from Jan 14, 2017
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+16 −1
Diff settings


Just for now

@@ -47,6 +47,16 @@
private final long buildStartTime;

* The last note time.
private long lastTime;

* The last encoded note. We can re-use this if the time hasn't since changed.
private byte[] lastNote;

* Create a new {@link TimestampNotesOutputStream}.
@@ -58,6 +68,7 @@
public TimestampNotesOutputStream(OutputStream delegate, long buildStartTime) {
this.delegate = checkNotNull(delegate);
this.buildStartTime = buildStartTime;
this.lastTime = 0;

@@ -66,7 +77,11 @@ public TimestampNotesOutputStream(OutputStream delegate, long buildStartTime) {
protected void eol(byte[] b, int len) throws IOException {
long now = System.currentTimeMillis();
new TimestampNote(now - buildStartTime, now).encodeTo(delegate);
if (now != lastTime) {
lastNote = new TimestampNote(now - buildStartTime, now).encode().getBytes("UTF-8");
lastTime = now;
delegate.write(b, 0, len);

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.