Skip to content

Commit 66a1803

Browse files
committed
Improve commenting of workaround
1 parent 63ee878 commit 66a1803

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/main/java/org/kohsuke/github/Requester.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,11 +897,16 @@ private <T> T parse(Class<T> type, T instance, int timeouts) throws IOException
897897
// to preserve backward compatibility
898898

899899
// WORKAROUND FOR ISSUE #669:
900-
// When caching GitHub doesn't handle "If-Modified-Since" correctly
901-
// In the case that an item didn't exist (returned 404) but now does exist
902-
// Accurate 404 responses from GitHub do not have ETag information (at this time)
903-
// If we see a 404 with an ETag we treat it as corrupt and make new request with
904-
// caching headers overridden to force refresh.
900+
// When the Requester detects a 404 response with an ETag (only happpens when the server's 304
901+
// is bogus and would cause cache corruption), try the query again with new request header
902+
// that forces the server to not return 304 and return new data instead.
903+
//
904+
// This solution is transparent to users of this library and automatically handles a
905+
// situation that was cause insidious and hard to debug bad responses in caching
906+
// scenarios. If GitHub ever fixes their issue and/or begins providing accurate ETags to
907+
// their 404 responses, this will result in at worst two requests being made for each 404
908+
// responses. However, only the second request will count against rate limit.
909+
905910
// If we tried this once already, don't try again.
906911
if (Objects.equals(uc.getRequestMethod(), "GET") && uc.getHeaderField("ETag") != null
907912
&& !Objects.equals(uc.getRequestProperty("Cache-Control"), "no-cache") && timeouts > 0) {

0 commit comments

Comments
 (0)