Reformatting the code with google-java-format tool in change Id5f3c6de9
resulted in wrapped lines being unwrapped to the new 100 columns limit.
In cases where the wrapped line was wrapped on a string concatenation,
the resulting long line now includes redundant concatenations. See the
upstream issue [1] for an example of this.
Squash the redundant concatenations with:
git ls-files | grep java$ | xargs sed -i '' 's/" + "//g'
(note: this also resulted in a couple of unwanted changes; those are
manually undone.)
[1] https://github.com/google/google-java-format/issues/122
Change-Id: I7348413ae460c8c7a0b0c72dab0a1ae7275a2ec3
Error Prone plans to make this pattern into a compile error; this avoids
future breakage.
In some of these cases, it's not obvious that ignoring the return value
is the correct thing to do; the hope is that the construct is ugly
enough to make the author think twice. In many cases though, it's clear
that a locally-created Runnable or Callable already does its own error
handling, so we can leave a comment alongside the ignored return value.
Eventually many of these should be audited again, and we can replace
some of the @SuppressWarnings with Error Prone's @CanIgnoreReturnValue.
That much is left for future cleanup.
Change-Id: Ia989214d85e0d6c387e388a77178e0b5c4bf2498
Having a standard tool for formatting saves reviewers' valuable time.
google-java-format is Google's standard formatter and is somewhat
inspired by gofmt[1]. This commit formats everything using
google-java-format version 1.2.
The downside of this one-off formatting is breaking blame. This can be
somewhat hacked around with a tool like git-hyper-blame[2], but it's
definitely not optimal until/unless this kind of feature makes its way
to git core.
Not in this change:
* Tool support, e.g. Eclipse. The command must be run manually [3].
* Documentation of best practice, e.g. new 100-column default.
[1] https://talks.golang.org/2015/gofmt-en.slide#3
[2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html
[3] git ls-files | grep java$ | xargs google-java-format -i
Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
Reformat the Bazel build files with the buildifier tool [1].
The style is different for Bazel files. Most notably, indentation level
is 4 spaces instead of 2, and " is used instead of '.
[1] https://github.com/bazelbuild/buildifier
Change-Id: I95c0c6f11b6d76572797853b4ebb5cee5ebd3c98
For some persistent caches we may want a larger default diskLimit than
the overall default of 128MiB.
Change-Id: I9f8c85d7187d2edfe5ba48ea27c7b5f5e37e7abe
These suggestions were produced by a refactoring tool that we have;
the particular decisions it made were based on heuristics over which I
have no control. Some suggestions were edited for brevity, and to omit
references to unreleased Guava features.
Change-Id: I9deac0afd6eda8fdc5a369816a4ee2bbe16924ba
Add separate configs for h2CacheSize for the cache tables and
normal persistent H2 dbs. While the caches offer further options
to limit their total size, normal table can grow without bounds,
so different H2 memory cache size seem reasonable.
H2 offers an auto server mode
(http://www.h2database.com/html/features.html#auto_mixed_mode).
Add a flag to enable this mode. This allow to run command line utils
that access the database (e.g.RebuildNoteDb) also for the embedded H2
database.
Add a flag to enable auto-server mode for the H2-based caches as
well.
Change-Id: Id4fe76363bc209064485296d4dd1697e0de0f235
To run the tests:
bazel test //...
To build the Gerrit plugin API, run:
bazel build gerrit-plugin-api:plugin-api_deploy.jar
To build the Gerrit extension API, run:
bazel build gerrit-extension-api:extension-api_deploy.jar
TODOs:
Licenses
Reduce visibility (all public for now)
Generate HTML Documentation
Core plugins
gerrit_plugin() rule to build plugins in tree and standalone modes
GWT UI (only gwt_module() skylark rule is provided, no gwt_binary())
PolyGerrit UI
WAR
Publish artifacts to Maven Central
Ask Bazel team to add Gerrit to their CI on ci.bazel.io
Contributed-By: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I9a86e670882a44a5c966579cdeb8ed79b1590de3
It's not necessary to use Guava's helper methods when instantiating
empty collections. Just use the native constructors.
Change-Id: I7f454909b15924ee49e149edf9f053da9f718502
I39f2d5d7 isolated jgit in its own cell, that is based on this JGit
Buck build implementation: [1]. Migration was done seamlessly, meant
that single BUCK file in lib/jgit represents JGit cell root location.
However, the real structure of JGit project is divided to number of
different sub-projects. To map between simplified JGit cell in gerrit
and real JGit project structure in JGit project, java_library() rules
were added to root BUCK file in JGit project that work like proxy to
real rules located in JGit sub-projects. For example //:jgit in JGit
tree was implemented as:
java_library(
name = 'jgit',
exported_deps = ['//org.eclipse.jgit:jgit'],
visibility = ['PUBLIC'],
)
Such proxies are needed for every artifact that is referenced from
gerrit build and make Buck build implementation unnecessary verbose.
Moreover this introduced some subtle issues, like using JGit
dependencies in context of java_doc rules, where $(location :foo) macro
is unable to resolve the underlying files because java_library with
exported dependencies only do not have association with output file.
An attempt to replace java_library with only exported dependenies with
prebuilt_jar: [2] that depends on the real artifact introduced another
problem with assembly of gerrit.war, because now jgit.jar is twice in
the classpath (because prebuilt_jar has output file association). To
fix this we would need to filter potential duplicates in the assembly
process of gerrit.war.
Instead of using proxy approach and to try to provide yet another
workaround to subtle problems, emulate the JGit project structure and
reference directly the same artifacts paths within gerrit JGit cell
in gerrit build:
deps = [
'@jgit//org.eclipse.jgit:jgit',
],
This simplifies JGit Buck build implementation, as we wouldn't need to
proxy all artifacts referenced from gerrit build from the root build
file. And this would fix all remaining issues.
This approach make gerrit build slightly more verbose. JGit upgrade
process would need to touch 4 files instead of only one. But given that
the Gerrit/JGit development integration is important feature, we would
like to support (as this integration attempt shows: [3]) in our build
toolchain, this overhead is justified.
With this change, the root build file in JGit project can be stripped:
[4].
[1] https://git.eclipse.org/r/61938
[2] https://git.eclipse.org/r/66547
[3] https://gerrit-review.googlesource.com/61892
[4] https://git.eclipse.org/r/66562
Change-Id: I2d278f80d0fedc4c5e9943804873f57145877dfe
H2 database by default uses up to the half of the amount of memory
available for the virtual machine (Runtime.getRuntime().maxMemory())
as described in [1]. In some cases this could contribute to an
out-of-memory error in Gerrit.
Introduce a new configuration parameter cache.h2CacheSize to limit
the H2 memory cache size. In this change this parameter is applied
to all persistent caches.
[1] http://www.h2database.com/html/features.html#cache_settings
Change-Id: I0217d4114f528275ca4094e0f3414ef23af80677
Consume JGit as first third party library from its own cell. Normally
the cell is defined as lib/jgit directory. It can be easily replaced
with CLI:
buck build --config repositories.jgit=path/to/dev/jgit gerrit
or tweaking the .buckconfig:
[repositories]
jgit = path/to/dev/jgit
The former approach is sufficient to build and run the test from the
CLI, the latter is needed to generate eclipse project.
To isolate the JGit rules in its own cell some refactoring was needed.
JGit patch for GWT module was moved to gerrit-patch-jgit project, and
some symlinks were needed for maven machinery to work. include_defs()
doesn't work for now across cell boundaries, and native `buck fetch`
feature still has some limitations: [1]. Moreover, excluding paths,
unsigning JARs and license linking should be re-implemented on top
of it.
[1] https://github.com/facebook/buck/issues/602
Test Plan:
Normal gerrit build and the build with hijacked JGit cell should work
in both standalone (gerrit.war) and Eclipse environment. Note, that
to test --config repositories.jgit=path/to/dev/jgit use case, the most
recent JGit tree must be used, that contains Buck driven build
implementation.
Change-Id: I39f2d5d75bbac88804406d6242b5e714f4916926
This method does not come for free from AbstractCache. Fortunately, it
is easy to implement by wrapping the provided Callable.
Change-Id: Ia3ad46dc87e54ddc6e8ee245e065ed4686c72e10
* stable-2.11:
Correct documentation of required capabilities for listing plugins
Always show 'Not Current' as state when looking at old patch set
Log IOExceptions on update of project configuration
H2: Don't show stack trace when failing to build BloomFilter
Update CodeMirror to 5.0 and consume from Maven Central
Add support to consume CodeMirror from org.webjars on Maven Central
Fix slave cloning issue by binding Scanning rather than Searching /index
Bump JGit version to 3.7.1.201504261725-r
Hybrid OpenID/OAuth: Check for session validity during logout
RestApiServlet: Leave OutputStream open when flushing base64 padding
RestApiServlet: Flush pending padding as well
Change-Id: Ib7fa8885cafea1e2dc300257c4dbaee3ef132df2
Also convert all remaining references that expect to resolve site_path
to a File, notably LocalDiskRepositoryManager.
Change-Id: I5ef6f6e3d7b3fe0418a470b079b4cc04bc9be4f6
Bump the gwtorm version, since gwtorm changed Schema and
StatementExecutor to be AutoCloseable. This allows us to simplify many
callers.
While we're in there, fix some usages of more javax.sql classes like
Statement that became AutoCloseable in Java 7.
Change-Id: Icf86fdb52a499563ccf2a7c761cc498ad758d99c
Since Java 7 it is possible to replace the type arguments required to
invoke the constructor of a generic class with an empty set of type
parameters (<>) as long as the compiler can infer the type arguments
from the context [1].
Enable the Eclipse warning about redundant type arguments, and remove
the ones it warns about.
[1] http://goo.gl/SG21kM
Change-Id: I422882949a6a6a57391580d881f73120b2843a0e
This reverts commit 5db3bba3e2d85662bacedc5d2f215fff7d8d2805.
I was too fast to submit 5db3bba. Besides forgetting to submit the
referenced changes in some submodules some people reported issues
with the interception of the javax.inject.Inject in some JEE containers.
Change-Id: I931ad329d2e7be6f6ce804b8395489a021c8240b
The Guice team is discouraging use of its specific annotation where
possible, to increase JSR330 compliance.
Leave optional injection alone for now, which needs to be manually
replaced with OptionalBinder.
Change-Id: I4f53a518ba6f36fd67af12f3540dc44cbad07ff8
The H2CacheImpl didn't honor the expireAfterWrite. This had an effect
that persisted entries never expired. For example, the web_sessions
cache entries didn't expire after their maxAge was reached.
Change-Id: I3a7c754ee05fe9ac92d96652db4b862bb597eba1
Signed-off-by: Saša Živkov <sasa.zivkov@sap.com>
Signed-off-by: Adrian Görler <adrian.goerler@sap.com>
GET /config/server/caches/ lists the server caches. Caches defined by
plugins are included.
The implementation of the SSH show-caches was adapted so that it uses
the new REST endpoint to get the information about the caches. This
avoids code duplication.
For disk caches a new interface was introduced in gerrit-server. This
is done because the list caches REST endpoint needs extra information
for disk caches which can only be provided by the disk cache, aka
H2CacheImpl. H2CacheImpl is defined in gerrit-cache-h2, but
gerrit-server doesn't have a dependency on it and hence can't use
instanceof to check whether a cache is a disk cache. Adding this
dependency is not wanted and also not possible (because
gerrit-cache-h2 already depends on gerrit-server and we can't have
cycles in the dependencies).
Change-Id: I21bf6e114310f98051a0a8db01012511f58d4add
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2e1cb2b8495761a7e9abc09ebca24ca6bbf2afbe switches from Ehcache to Guava
for providing caching in Gerrit and claims that one of the advantages of
using Guava is that it enables caches to be build at any time, rather
than only at server startup. Therefore, I guess it is OK to remove the
precondition check which prevents creation of caches once the server was
started.
This enables plugins to create own persistent caches when they are
installed.
Change-Id: I28b1a140c58f9967e6d1dacd61ddd021b48c8ad5
Cut down on a bunch of one-offs of install(new *Module() {...}) by
choosing a more appropriate base module class. This doesn't solve all
such cases, for example RpcServletModule must still inherit from
ServletModule, but it does clean up some code. (And who knows, fewer
modules may even mean faster startup time.)
Change-Id: Ie1aed05d0a64f7f11b121c9a637bb30d80e9a595
* stable-2.7:
Bump JSch to 1.5.0 to fix Java7 compatibility
Extend AddBranchResult with toString method implementation
Get rid of JdbcSQLException while numbers are read from cache
Conflicts:
gerrit-common/src/main/java/com/google/gerrit/common/data/AddBranchResult.java
pom.xml
Change-Id: Ic3bae80a40bfa2d8e8eee598bcdbd771b99cbeda
* stable-2.6:
Bump JSch to 1.5.0 to fix Java7 compatibility
Extend AddBranchResult with toString method implementation
Get rid of JdbcSQLException while numbers are read from cache
Exception org.h2.jdbc.JdbcSQLException: Hexadecimal string with odd
number of characters: "0" is thrown when number with value 0 or string
with value "0" is stored in H2Cache and read is performed.
The fix modifies implementation so that Java de-serialization is
performed even for built-in (e.g. Integer) types.
Change-Id: I953487cb75b3712e8825a74613977425873507a1
Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
This method from joda-time supports replacing the system time provider
with a custom provider for tests. Since it is verbose, and we expect
more related methods, put it in the more succinct TimeUtil.nowMs().
This commit covers the trivial cases in the server side; client-side
code still uses System.currentTimeMillis().
Change-Id: I6c56e8c5bbb0cf7b0271e431d1ebdb532967b9e8