Repository navigation
Conversation
JhlAnnotations parsed the full svn:date revprop with a SimpleDateFormat pattern ending in .SSS. svn:date has microsecond resolution, and the lenient parser consumed all six fractional digits as milliseconds, so every Date returned by blame/annotate was up to 999 seconds (~16 min) in the future, by a different amount per revision. Parse with java.time.Instant instead, which understands ISO-8601 fractional seconds and the trailing Z. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
This seems legit but I am just not sure if this code is really worth considering active or maintained any more. I certainly do not see any releases being produced |
There was a problem hiding this comment.
🟡 Changes recommended
Date decoding remains platform-dependent, and the timestamp fix lacks regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes incorrect JavaHL blame timestamps by parsing svn:date with Instant.
Changes:
- Replaces lenient millisecond parsing with ISO-8601 parsing.
- Wraps parse failures as
ClientException.
File summaries
| File | Description |
|---|---|
JhlAnnotations.java |
Corrects blame timestamp parsing. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| * the trailing <code>Z</code> correctly. | ||
| */ | ||
| private static Date parseSvnDate(byte[] date) { | ||
| return Date.from(Instant.parse(new String(date))); |
Comment on lines
+50
to
+51
| private static Date parseSvnDate(byte[] date) { | ||
| return Date.from(Instant.parse(new String(date))); |
Author
|
Thanks for pointing that out. Of course, that doesn't make sense. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Every timestamp reported by
blame/annotatethrough the JavaHL adapter is inthe future — by a different amount for each revision, up to ~16 minutes.
Root cause
javahl/src/main/java/org/tigris/subversion/svnclientadapter/javahl/JhlAnnotations.java:39declares
and
singleLine(...)parses the completesvn:daterevprop with it (lines 88 and 92):svn:datehas microsecond resolution, e.g.2011-07-31T12:58:47.840123Z.SimpleDateFormatis lenient by default, so theSSSfield swallows all sixfractional digits and interprets
840123as milliseconds; the trailingZis ignored by
parse(String)as trailing text. The result is shifted forward byfractionmilliseconds — 0 to 999999 ms, i.e. up to 16 min 39 s.This is not a time zone problem:
SafeSimpleDateFormatalready pins itsinternal formatter to UTC.
JhlLogMessagein the same package gets this right by truncating the string to23 characters before parsing;
JhlAnnotationsnever got the same treatment.Reproduction
OpenJDK,
TZ=Europe/Berlin, formatted asdd.MM.yyyy HH:mm:ss:2026-07-31T12:58:47.840123Z31.07.2026 15:12:4731.07.2026 14:58:472026-07-31T12:58:47.999999Z31.07.2026 15:15:2631.07.2026 14:58:472026-01-15T09:00:00.000000Z15.01.2026 10:00:0015.01.2026 10:00:00The drift is
999.0 sin the worst case and0 sonly when the fraction is zero.Fix
Replaced the formatter with a private helper that parses via
java.time.Instant.parse(...):Why
Instantrather than truncating to 23 characters likeJhlLogMessage:Instant.parseis the ISO-8601 parser this value actually calls for. It handlesany number of fractional digits and the
Zsuffix by specification instead ofrelying on a fixed string length, it is strict (a malformed value fails instead
of being silently reinterpreted), and it removes the lenient-
SimpleDateFormatfootgun from the file entirely.
java.timeis available — the build targetsJava 8 (
maven-compiler-pluginsource/target1.8).Because
Instant.parsethrows the uncheckedDateTimeParseExceptionratherthan
ParseException, the existingcatchwas retargeted so a malformed valuestill surfaces as a
ClientException, as before.Scope
Helper.xmlFormatusesyyyy-MM-dd'T'HH:mm:sswith no fractional-seconds field.SvnKitClientAdapter extends AbstractJhlClientAdapterand instantiatesJhlAnnotations.JhlLogMessageis left alone — its 23-character truncation is already correct.Build note
mvn -pl base,javahl -am compilebuildsbasebut cannot resolveorg.apache.subversion:javahl:1.14.0, which is served fromhttps://maven.pkg.github.com/subclipse/javahland returns401 Unauthorizedwithout credentials. The changed file was therefore verified by compiling it
with
javac --release 8against the builtbaseclasses plus minimal stubs forClientExceptionandBlameCallback; it compiles clean, so the change issyntactically valid and Java 8 compatible. Please let CI do the real javahl build.
🤖 Generated with Claude Code