1393 Commits

Author SHA1 Message Date
Dave Borowitz
cc7b9a82e3 Move ByteString bytes(int... ints) to test util
Change-Id: If55dac7c1a2df87c412bf0e13afb7a9b57fbfa95
2018-05-14 14:26:50 -07:00
Dave Borowitz
095394c069 Add tests for fields declared in types with custom serializers
When the set of fields changed, it's a very good sign that something
needs to change in the serializer implementation, or at least bumping
the version number in the CacheMoule. Add a simple test utility that
maps declared field names to types, and list the expected types
explicitly in each of the relevant tests.

This simple mechanism can't catch everything, for example:

 * If the serializer implementation changes for an existing type in an
   incompatible way, without altering any fields. In this case, the
   {key,value}Serializer in the CacheModule will change, so hopefully a
   reviewer will notice and ask the author to bump the version as well.
 * If semantics of individual fields change without changing the type,
   such as making a field newly @Nullable.

But it's much better than nothing.

Change-Id: I51e60b83f9c3291d2f8f9ac19ce0192678211676
2018-05-14 14:26:50 -07:00
Dave Borowitz
e6930d73b0 Convert OAuthTokenCache serialization to protobuf
The serializer class lives in OAuthTokenCache.java so the extension
framework doesn't acquire a dep on the cache serialization code, which
currently lives in the server package.

Proto3 doesn't have optional fields, so we can't distinguish between
empty and null for the provider_id field (at least without adding a
separate has_provider_id field). Explicitly treat these the same in
OAuthToken itself, and clarify that other fields are not nullable.

Change-Id: I37bd47ac0c8491e5212fcec4885e063ae50d714d
2018-05-14 14:26:50 -07:00
Dave Borowitz
e62a11110a Convert MergeabilityCacheImpl.Key serialization to protobuf
Change-Id: If3e2d0821b700acd408c2c6052dea2f5e208805b
2018-05-14 14:26:50 -07:00
Dave Borowitz
52e5bbbbc1 Simplify and clarify exception throwing of CacheSerializer
Previously, CacheSerializer threw IOException for the convenience of
implementors, since some implementations were based on APIs like
InputStream/OutputStream that threw IOException. However, this didn't
cover all the possible exceptions that could be thrown; callers also
neded to be prepared to catch RuntimeException. Throwing checked
exceptions in some case and unchecked exceptions in others might have
given the impression that these cases were fundamentally different and
required different handling, which is not the case.

In addition, generally speaking, these classes are null-hostile. Use
checkNotNull in EnumCacheSerializer so the intent is clear.

Also in EnumCacheSerializer, delegate to Enums#stringConverter rather
than rolling our own.

Change-Id: I37f1cf73d961be477af389c4043bb1c10c45972c
2018-05-14 14:26:50 -07:00
Edwin Kempin
0af4aa9095 Merge "Make GerritApiImpl class public" 2018-05-14 08:35:57 +00:00
Edwin Kempin
727d718b77 Make GerritApiImpl class public
This allows us to bind this class in our custom Guice stack at
Google.

Change-Id: I2307538a30e80f388346455ff17ef3710bc9ce8c
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-14 08:33:48 +00:00
Edwin Kempin
43e3c48bbc SshDaemon: Fix logging
All logging of this class should be done through the locally defined
'sshDaemonLog' Logger (and not through the inherited 'log' Logger from
AbstractLoggingBean).

Change-Id: I2d1031fe51601f11911b110c482482ff2482ce1a
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-14 09:40:22 +02:00
David Pursehouse
56d5b5b128 Merge "Make GitwebServlet use Provider<CurrentUser>" 2018-05-14 04:08:14 +00:00
Wyatt Allen
78ef01e3af change.allowBlame config only disables in the GWT UI
Because of problems in the GWT UI's display of blame annotations, the
change.allowBlame config was used to disable the Gerrit feature
altogether. Since then, the PolyGerrit UI can display blame annotations
without these problems, but the feature remains disabled.

The change.allowBlame config handling is changed to only disable blame
in the frontend of the GWT UI. Note: this removes the ability to disable
the blame API via server config.

Change-Id: Ic25aed5a533e0044956359587321676b022c21ec
2018-05-10 09:52:21 -07:00
David Pursehouse
308d1fcd5a Merge branch 'stable-2.15'
* stable-2.15:
  Update git submodules
  WorkQueue: Add metrics
  Update git submodules
  Revert "Revert "Filter account entry suggestions""
  Switch to 2.14.9-SNAPSHOT version

Change-Id: I6ba156d6b014336e1faeafa85440a2c86fab0dc6
2018-05-10 11:11:48 +09:00
Maxime Guerreiro
9f95562605 Merge "Bind a DynamicSet to SubmitRule" 2018-05-09 15:59:59 +00:00
Maxime Guerreiro
14aec6f42b Bind a DynamicSet to SubmitRule
Without this, rules can't be used in the offline reindexer.

Change-Id: I2bab5f5385de1a6da5fca7dbafd7ca3148492408
2018-05-09 15:09:51 +00:00
Patrick Hiesel
567a53c016 Make GitwebServlet use Provider<CurrentUser>
This was wrongly changed in I601ea1200a. This commit changes it back to
the correct value (a provider of the CurrentUser).

Change-Id: I6cbee0cd3013e6fc53514db4c1b855e8da52e63b
2018-05-09 13:41:04 +02:00
Patrick Hiesel
e638d589fa Enforce a maximum PER_THREAD_CACHE_SIZE in PerThreadCache
When calling operations that create a lot of ProjectControls (e.g.
ListProjects) we observe OOMs in our Gerrit jobs from time to time. This
commit puts a max. limit on the cache size to prevent this from
happening.

The approach implemented is not an LRU. On purpose, we want to keep
PerThreadCache simple and don't add a dependency on e.g. Guava's LRU.

Change-Id: Ic2f6e11719b52ee2112f72698e887cbf8ca254d0
2018-05-09 12:06:55 +02:00
David Pursehouse
9f7b81b1d6 Merge branch 'stable-2.15'
* stable-2.15:
  Revert "Filter account entry suggestions"
  ChangeIndexedListener: pass project name information
  Set version to 2.15.2-SNAPSHOT

Change-Id: Id36088686621e5ce4c61633d8df732a49d205209
2018-05-09 08:49:33 +09:00
David Pursehouse
bc58feda76 Merge "Replace all lambdas with method references, when possible" 2018-05-08 23:20:32 +00:00
Hugo Arès
8eb1599e95 Merge "Merge branch 'stable-2.15'" 2018-05-08 20:57:16 +00:00
Maxime Guerreiro
609f9826e5 Replace all lambdas with method references, when possible
Every time a lambda taking an argument is created, an object is created.
This object is unique and makes it harder for the JIT compilation to
optimize the code.

By replacing lambdas with method references, we help the JIT better
understand our code, and reduce object creations* and garbage
collection.

Using method references also helps humans better understand the code,
and might even make compilation faster: the method, and where it lives,
is explicitely written: no need to guess it.

    repoUpgraded.stream().map(n -> n.get()).collect(...);
Where does the get method come from? Hard to tell.

    repoUpgraded.stream().map(NameKey::get).collect()
Same line of code, using a method reference. It is clear that the input
objects are NameKey-s, and we call the get method on them.

* This is technically wrong, as a pointer is created even when we use a
method reference, but it is at least smaller than the lambda
counterpart.

Change-Id: Ic85b1b593d42968f262d3afe49a2ad87a4b766b9
2018-05-08 15:13:24 +00:00
Patrick Hiesel
4a56ff0171 Instrument RestView#getDescription to analyze slow UIActions
UIActions (GetRevisionActions) calls have a 99.9%ile latency > 1 minute.
We only have metrics on the REST endpoint which does not give much
indication on why this endpoint is slow.

UIActions is implemented in a way that it calls #getDescription on all
RestViews that implement the UIActions interface. This means we do
serial calls to a lot of these methods. This commit adds a latency
metric to instrument these calls. Knowing which actions are slow can
guide futher steps that we take.

Possibilities include reworking slow actions or looking into more
parallelism.

Change-Id: I261bfb1a5a43b81f11dba019d405126198908c5f
2018-05-08 15:33:45 +02:00
David Pursehouse
9b13ad0652 Merge branch 'stable-2.15'
* stable-2.15:
  Disable draft magic branch option per default
  GetUserFilter: Allow to include username in servlet response header
  WorkQueue: Don't lazy-initialize the default queue

Change-Id: I36726fc943df542494925c5f2d1e67ddeb95a21a
2018-05-08 17:03:23 +09:00
David Pursehouse
a72fbf418e Merge changes from topic "change-messages-rest-api"
* changes:
  Add REST endpoint to get one change message
  Add REST endpoint for listing change messages
2018-05-08 01:11:55 +00:00
David Pursehouse
d1aacd1d35 Merge branch 'stable-2.15'
* stable-2.15:
  CommentEvent: Fix parameters in log message
  DiffSummaryLoader: Remove unused logger
  EventUtil: Always say 'event listener' in logs
  EventFactory: Log PatchListNotAvailableException always as error
  EventFactory: Log exception when getting commit message fails
  TrackingFootersProvider: Fix spelling mistake in log message
  WorkQueue: Add comment on additional constructor

Change-Id: I841f6008a9aad198a567d03bce5c6482f1bcb9a6
2018-05-08 09:12:31 +09:00
David Pursehouse
36503ce573 Merge "Restore 'notedb/external_id_update_count' metric" 2018-05-07 23:26:37 +00:00
David Pursehouse
1ed7d702da Merge changes I38c38946,I2ffbba76,I729e7856,I447a00cc,I0104a280, ...
* changes:
  DiffSummaryLoader: Remove unused logger
  CommentEvent: Fix parameters in log message
  AutoReplyMailFilter: Fix parameters in log messages
  EventUtil: Always say 'event listener' in logs
  EventFactory: Log PatchListNotAvailableException always as error
  EventFactory: Log exception when getting commit message fails
  TrackingFootersProvider: Fix spelling mistake in log message
2018-05-07 20:27:36 +00:00
Patrick Hiesel
144e4c52fa Merge "Document that repo in ForProject#filter() must be scoped to the project" 2018-05-07 16:37:05 +00:00
Edwin Kempin
b508fa7178 DiffSummaryLoader: Remove unused logger
Change-Id: I38c3894698dcfd0c97f6d12f04986fb2f0ba0efb
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-07 15:31:09 +02:00
Edwin Kempin
216c67038f CommentEvent: Fix parameters in log message
The log message had 3 parameters, but only 2 placeholders in the format
string.

Change-Id: I2ffbba76837adb92d924a8692913b6ef3e675f30
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-07 15:31:09 +02:00
Edwin Kempin
bb4e518208 AutoReplyMailFilter: Fix parameters in log messages
We must use '{}' as placeholders for the parameters.

Change-Id: I729e7856882c0b37a4c6e19f022c981876ef8c95
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-07 15:31:09 +02:00
Edwin Kempin
3db67d6050 EventUtil: Always say 'event listener' in logs
The debug logs say 'event listener', but the warning logs just
'listener'. Make this consistent and always use 'event listener' which
is more precise.

Change-Id: I447a00cce0b11e5337801ce5d84c7954c1340f59
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-07 15:31:09 +02:00
Edwin Kempin
1ea84c5d83 EventFactory: Log PatchListNotAvailableException always as error
There is only one place where PatchListNotAvailableException is logged
as a warning, everywhere else (EventFactory, ChangeAbandoned,
ChangeMerged, ...) it is logged as an error. Make this consistent.

Change-Id: I0104a280c984e2c8244618fa518b320bad0407af
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-07 15:31:09 +02:00
Edwin Kempin
e73f1ea0bf EventFactory: Log exception when getting commit message fails
Without the stacktrace the error log is not very useful.

Change-Id: I29688404e51f999bc06c6ec47b2de5bd1a6e238d
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-07 15:31:09 +02:00
Edwin Kempin
ef53f46c8e TrackingFootersProvider: Fix spelling mistake in log message
Change-Id: I7ed9ba1eca6e61d86debc47c292e224ed7ffcb7d
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-07 15:31:09 +02:00
David Pursehouse
3650cb9f56 Merge branch 'stable-2.15'
* stable-2.15:
  gr-change-metadata: Change "Hashtag" label to "Hashtags"
  ChangeScreen: Add missing 'Hashtags' label
  WorkQueue: Make defaultQueueSize final

Change-Id: I6b55a11f4b4cfffa66f4e044be325c3c8e81622b
2018-05-07 16:51:51 +09:00
Patrick Hiesel
5c2cb2d668 Document that repo in ForProject#filter() must be scoped to the project
Change-Id: I874124896029aeae85b946bb1a81410e693b3cd4
2018-05-07 09:19:19 +02:00
Edwin Kempin
9e511133ed Restore 'notedb/external_id_update_count' metric
This metric measures the total number of external ID updates. It was
unintentionally removed by change I8946f0de5c when AccountsUpdate took
over the responsibility to update external IDs and ExternalIdsUpdate was
removed [1].

[1] https://gerrit-review.googlesource.com/c/gerrit/+/150333/9/java/com/google/gerrit/server/account/externalids/ExternalIdsUpdate.java

Change-Id: I19c2e847dac3b26109387bd90768e09dc9cd422c
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-05-07 09:11:10 +02:00
Edwin Kempin
824847b1a8 Merge "GroupBundle.Action: Make 'order' member final" 2018-05-07 06:11:48 +00:00
David Pursehouse
b5e1bee5eb Merge "Add ability to specify base commit in Create Change API" 2018-05-07 05:20:36 +00:00
David Pursehouse
387bcf438b GroupBundle.Action: Make 'order' member final
Change-Id: I19528ca3c10c5c65b38a52621c310282d4de2954
2018-05-07 14:17:51 +09:00
David Pursehouse
469bea568d Merge "Use Collections.addAll to copy elements from an array to collections" 2018-05-06 23:35:29 +00:00
David Pursehouse
6ad528ae8a Merge "Collapse loops using the removeIf syntax" 2018-05-06 23:34:08 +00:00
Maxime Guerreiro
2eca6e58e0 Merge changes I3a964bae,Iefb4984f,I55605153
* changes:
  Add a helper method to fetch the commit message
  Add tests triggering RULE_ERROR in Prolog
  Add a way to disable the account index from tests
2018-05-04 08:47:16 +00:00
Maxime Guerreiro
7d80d5764c Collapse loops using the removeIf syntax
Change-Id: I9d51ad16f375541f6cd0a7f231d5f2771d7c3ef9
2018-05-03 17:14:36 +00:00
Maxime Guerreiro
05ce4c2414 Add a helper method to fetch the commit message
The PRED_commit_message_1 rule doesn't need the whole PatchSetInfo
values to be loaded to function properly: only the commit message is
required.

This change improves this by only loading the commit message from the
repository.
Fix a test case: the commit_message predicate does not use the account
index anymore. Before that, it was indirectly used to gather
informations on the author and committer. These two informations were
loaded but never used.

Change-Id: I3a964bae3512ee6fba7895739f32fd592e8595bf
2018-05-03 16:40:11 +00:00
Maxime Guerreiro
ff49720b2b Add a way to disable the account index from tests
Change-Id: I556051539085e949ddbc8084210928992a667562
2018-05-03 14:03:43 +00:00
Dave Borowitz
6226dce0d1 ApprovalsUtil: Remove unused userFactory field
Change-Id: Ibfe7d33df2f674171d3086a8af7a739c68347baa
2018-05-03 09:25:54 -04:00
Dave Borowitz
80a4daa1bd Merge changes from topic "proto-cache"
* changes:
  TagCache: Make EntryVal class public
  CacheModule: Expose bindings for (Persistent)CacheDef
  Custom serializers for ChangeKindCache, including protobuf
  Manage persistent cache versioning outside of Java serialization
  Allow alternative serialization strategies for persistent caches
  Factor KeyType singleton implementations into their own classes
  Factor out KeyType interface from H2CacheImpl
  Add Persistent subclasses of Cache{Binding,Def,Provider}
  Split setter/getter interfaces out of CacheBinding
2018-05-03 13:04:13 +00:00
Patrick Hiesel
168d343be6 Merge "Cleanup callers of PermissionBackend#user()" 2018-05-03 12:43:26 +00:00
David Pursehouse
ba0f47ca56 Merge branch 'stable-2.15'
* stable-2.15:
  Define a floor for NoteDb sequence generation

Change-Id: I7a4d0ca6448131cb50a1e36d746f291341bedb6b
2018-05-03 18:43:30 +09:00
Patrick Hiesel
70870059cd Cleanup callers of PermissionBackend#user()
This commit moves callers of PermissionBackend#user() to call
PermissionBackend#currentUser() in cases where the user for the
previous call could only come from the Injector and where we don't
already need a CurrentUser object in the class.

It migrates callers that explicitly check permissions of absent users to
call PermissionBackend#absentUser().

In cases where we check permissions of absent users that could also be
unauthenticated, checks for anonymous users are made explicitly.

Change-Id: I6b470790e89b69077650fed42cb61dfeeb404b6e
2018-05-03 11:31:23 +02:00