Skip to content

Commit

Permalink
Run google-java-format on all Guice code.
Browse files Browse the repository at this point in the history
configure a presubmit to ensure that it stays formatted.

Highlights include:
* simplified import order
* method annotations are now consistently defined on the preceding line
* javadoc reformatted to 100 chars column width

One test that contained line numbers in error messages had to be modified and
the formatter didn't like some of the more complicated preprocessor directives
(MOE and AOP).

To avoid formatting the copyright notices as javadoc i did a preprocessing step to rewrite the initial '/**' to '/*' using perl

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132889350
  • Loading branch information
lukesandberg authored and sameb committed Sep 13, 2016
1 parent 3137d25 commit 2a013d3
Show file tree
Hide file tree
Showing 12 changed files with 2,785 additions and 1,997 deletions.
12 changes: 6 additions & 6 deletions core/test/com/google/inject/internal/Collector.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,8 +22,8 @@
import com.google.inject.multibindings.OptionalBinderBinding;
import com.google.inject.spi.DefaultBindingTargetVisitor;

class Collector extends DefaultBindingTargetVisitor<Object, Object> implements
MultibindingsTargetVisitor<Object, Object> {
class Collector extends DefaultBindingTargetVisitor<Object, Object>
implements MultibindingsTargetVisitor<Object, Object> {
MapBinderBinding<? extends Object> mapbinding;
MultibinderBinding<? extends Object> setbinding;
OptionalBinderBinding<? extends Object> optionalbinding;
Expand All @@ -36,10 +36,10 @@ public Object visit(MapBinderBinding<? extends Object> mapbinding) {

@Override
public Object visit(MultibinderBinding<? extends Object> multibinding) {
this.setbinding = multibinding;
return null;
this.setbinding = multibinding;
return null;
}

@Override
public Object visit(OptionalBinderBinding<? extends Object> optionalbinding) {
this.optionalbinding = optionalbinding;
Expand Down
20 changes: 11 additions & 9 deletions core/test/com/google/inject/internal/CycleDetectingLockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import com.google.inject.internal.CycleDetectingLock.CycleDetectingLockFactory;
import com.google.inject.internal.CycleDetectingLock.CycleDetectingLockFactory.ReentrantCycleDetectingLock;

import junit.framework.TestCase;

import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import junit.framework.TestCase;

public class CycleDetectingLockTest extends TestCase {

Expand All @@ -28,8 +26,8 @@ public class CycleDetectingLockTest extends TestCase {
* T1: Finishes locking B, unlocks B, unlocks A
* </pre>
*
* <p>This should succeed, even though T1 was locked on T2 and T2 is locked on T1 when T2 locks
* A. Incorrect implementation detects a cycle waiting on S3.
* <p>This should succeed, even though T1 was locked on T2 and T2 is locked on T1 when T2 locks A.
* Incorrect implementation detects a cycle waiting on S3.
*/

public void testSingletonThreadsRuntimeCircularDependency() throws Exception {
Expand All @@ -38,7 +36,9 @@ public void testSingletonThreadsRuntimeCircularDependency() throws Exception {
final CyclicBarrier signal3 = new CyclicBarrier(2);
final CycleDetectingLockFactory<String> lockFactory = new CycleDetectingLockFactory<String>();
final CycleDetectingLock<String> lockA =
new ReentrantCycleDetectingLock<String>(lockFactory, "A",
new ReentrantCycleDetectingLock<String>(
lockFactory,
"A",
new ReentrantLock() {
@Override
public void lock() {
Expand All @@ -55,7 +55,9 @@ public void lock() {
}
});
final CycleDetectingLock<String> lockB =
new ReentrantCycleDetectingLock<String>(lockFactory, "B",
new ReentrantCycleDetectingLock<String>(
lockFactory,
"B",
new ReentrantLock() {
@Override
public void lock() {
Expand Down Expand Up @@ -118,8 +120,8 @@ public Void call() throws Exception {
* Thread B: lock a lock A (factory A)
* </pre>
*
* <p>This should succeed even though from the point of view of each individual factory
* there are no deadlocks to detect.
* <p>This should succeed even though from the point of view of each individual factory there are
* no deadlocks to detect.
*/

public void testCycleDetectingLockFactoriesDoNotDeadlock() throws Exception {
Expand Down
Loading

0 comments on commit 2a013d3

Please sign in to comment.