Passing loggers between classes is bad and we should avoid this if
possible.
ValidationError#createLoggerSink required to pass in a logger just to
return it back to the caller wrapped in a lambda. Remove this method and
instead create the lambda directly in the caller. This brings us minimal
code duplication for formatting the message, but it's better than
passing the logger around.
Change-Id: I6b475de50fb2a1745c16ac424e0a95d358aaaf7d
Signed-off-by: Edwin Kempin <ekempin@google.com>
* Handle AuthenticationFailedException separately:
This exception is a subclass of AccountException that is thrown if the
user provides wrong credentials. For this exception we want to return
"Invalid username or password." as message to the client.
* Return a more general message for other AccountExceptions:
Likely they are not caused by invalid username or password since this
would cause a AuthenticationFailedException which we handle before.
* Increase log level to warning:
This is the log level that we use for these exceptions in other places
(e.g. ProjectBasicAuthFilter). Make it consistent.
* Log the stacktrace for AccountExceptions:
We do this everywhere else (e.g. ProjectBasicAuthFilter,
HttpLoginServlet). Make it consistent.
Change-Id: Ie34687d087b5a6cd102bf8cebd0f9830f54c9c1c
Signed-off-by: Edwin Kempin <ekempin@google.com>
Having the stacktrace when debugging this seems to be useful.
Change-Id: Ifa298ffb74eabdf0c6522c9831c533dd2ebd02eb
Signed-off-by: Edwin Kempin <ekempin@google.com>
Previously, expanding an inline diff toggled the reviewed state for that
file. This is wrong -- expanding the diff should just mark the file as
reviewed, not unreviewed.
Change-Id: I5533a3f286fbd2db2b9437f4cbf4fa546d347304
The _fetchSharedCacheURL is updated to accept Defs.FetchJSONRequest
parameters just like its underlying fetch utility methods.
Feature: Issue 8324
Change-Id: Ia087ee6daadf3ae5d20f4ddad80131895d17191c
The _getChangeURLAndFetch method took many optional arguments, making
call sites difficult to read and making the method difficult to make
changes to.
Refactor the optional arguments into an object with optional properties.
The new Defs.ChangeFetchRequest ensures that the objects are well-typed
and call sites are updated as well as tests.
Feature: Issue 8324
Change-Id: Icc1265613d84008a794670d3730136b1ade047f5
Two utility methods in the REST API interface for fetching JSON (named
_fetchJSON and _fetchRawJSON) took many optional arguments. This made
call sites difficult to read optional parameters would tend to spread
upwards to higher-level methods that use them.
Refactor the argument lists of these two methods into objects with
optional properties. The Defs.FetchJSONRequest typedef ensures that the
objects are well-typed. The utility method call sites and tests are
updated.
Feature: Issue 8324
Change-Id: I7e4cd242d961629b08b046a9d05469c09f6053bf
There is no good reason why depending on //lib/truth should free
downstream libraries from needing a direct dep on //lib/guava or
//lib/junit. Exporting the deps was probably just oversight, since the
distinction between exports and runtime_deps in WORKSPACE is not
obvious, and there are probably other bad examples.
Change-Id: I1530106d642167eaa25222cc95c3996478728e15
The _fetchJSON method is an internal utility to the REST API interface
and isn't used outside of it. Rename the method to mark it as private.
Change-Id: Ic9f860f0d9d555f6995b7154525416ee7a1f6bd8
We can just rely on the toString formatting of the List. This makes the
code more readable.
Change-Id: I98f0da6b5180198b9fcf0e45271e12e9ab182a52
Signed-off-by: Edwin Kempin <ekempin@google.com>
"log and throw" is considered a poor practice. The logging is uneeded
since the thrown exception will be logged somewhere else.
Change-Id: I82c210fe1e053a4ffd7a58b7fc7de6056f9875a7
Signed-off-by: Edwin Kempin <ekempin@google.com>
If a separate log statement is written for each line then the entries in
the log file can be interleaved with log entries from other threads,
which makes them less readable.
Change-Id: I038a0d8bc906746cc23b8f3bfb31d6c4d98b53c0
Signed-off-by: Edwin Kempin <ekempin@google.com>
Especially it's seems odd that copyStderrToLog logs the input on error
level but failing to do so results only in a debug log.
Change-Id: I52302be34e8f4a62639015acffe26d0a11a5c8da
Signed-off-by: Edwin Kempin <ekempin@google.com>
We used ProcessBuilder#toString() but ProcessBuilder doesn't implement
the toString() method, hence calling toString() would return the
instance identity (e.g. 'java.lang.ProcessBuilder@4488aabb'). Instead
include the command which is more useful.
This issue was detected by ErrorProne.
Change-Id: I780f21bbfeae8e7c1b3f4467d789bcf148293324
Signed-off-by: Edwin Kempin <ekempin@google.com>
We used to think adding this method to the top level is enough
and could avoid misuses. But it turns out we still need them in
other permission backend classes so that we only need to rescope
a user when necessary, which could provide better performance.
See I67b72b59 as an example.
Change-Id: I9ef30fb38315250fa63fb8b3d27e19e19d5e3e22
A colon is used as separator between the scheme and id. The logic in
ExternalId.Key#parse(String) that parses an external ID string looks for
the first occurrance of a colon to split the string. This means the
scheme must not contain any colon. Since a scheme is optional also the
id must not contain any colon.
We can't enforce this since internally at Google we violate this
assumption, but we also have our own parse logic and don't rely on the
parse logic in ExternalId.Key#parse(String).
Change-Id: I9a20776c6546eb09562f3da8f8e41506a74ba1e1
Signed-off-by: Edwin Kempin <ekempin@google.com>
Detect file list row template instantiation via a binding to find the
time that the last file in the list is shown. This allows for
approximation of the overall render time for the list.
Change-Id: I9090ed4e65f1b8751696d1d9cffcd815f2686359