The following issues were found

guava/src/com/google/common/collect/ForwardingMapEntry.java
9 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 65

                @Override
  @ParametricNullness
  public K getKey() {
    return delegate().getKey();
  }

  @Override
  @ParametricNullness
  public V getValue() {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 71

                @Override
  @ParametricNullness
  public V getValue() {
    return delegate().getValue();
  }

  @Override
  @ParametricNullness
  public V setValue(@ParametricNullness V value) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 77

                @Override
  @ParametricNullness
  public V setValue(@ParametricNullness V value) {
    return delegate().setValue(value);
  }

  @Override
  public boolean equals(@CheckForNull Object object) {
    return delegate().equals(object);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 82

              
  @Override
  public boolean equals(@CheckForNull Object object) {
    return delegate().equals(object);
  }

  @Override
  public int hashCode() {
    return delegate().hashCode();

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 87

              
  @Override
  public int hashCode() {
    return delegate().hashCode();
  }

  /**
   * A sensible definition of {@link #equals(Object)} in terms of {@link #getKey()} and {@link
   * #getValue()}. If you override either of these methods, you may wish to override {@link

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 100

                protected boolean standardEquals(@CheckForNull Object object) {
    if (object instanceof Entry) {
      Entry<?, ?> that = (Entry<?, ?>) object;
      return Objects.equal(this.getKey(), that.getKey())
          && Objects.equal(this.getValue(), that.getValue());
    }
    return false;
  }


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 101

                  if (object instanceof Entry) {
      Entry<?, ?> that = (Entry<?, ?>) object;
      return Objects.equal(this.getKey(), that.getKey())
          && Objects.equal(this.getValue(), that.getValue());
    }
    return false;
  }

  /**

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 116

                protected int standardHashCode() {
    K k = getKey();
    V v = getValue();
    return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode());
  }

  /**
   * A sensible definition of {@link #toString} in terms of {@link #getKey} and {@link #getValue}.
   * If you override either of these methods, you may wish to override {@link #equals} to forward to

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 116

                protected int standardHashCode() {
    K k = getKey();
    V v = getValue();
    return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode());
  }

  /**
   * A sensible definition of {@link #toString} in terms of {@link #getKey} and {@link #getValue}.
   * If you override either of these methods, you may wish to override {@link #equals} to forward to

            

Reported by PMD.

guava/src/com/google/common/io/Resources.java
9 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 64

                /** A byte source that reads from a URL using {@link URL#openStream()}. */
  private static final class UrlByteSource extends ByteSource {

    private final URL url;

    private UrlByteSource(URL url) {
      this.url = checkNotNull(url);
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 87

                 * @since 14.0
   */
  public static CharSource asCharSource(URL url, Charset charset) {
    return asByteSource(url).asCharSource(charset);
  }

  /**
   * Reads all bytes from a URL into a byte array.
   *

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 98

                 * @throws IOException if an I/O error occurs
   */
  public static byte[] toByteArray(URL url) throws IOException {
    return asByteSource(url).read();
  }

  /**
   * Reads all characters from a URL into a {@link String}, using the given character set.
   *

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 111

                 * @throws IOException if an I/O error occurs.
   */
  public static String toString(URL url, Charset charset) throws IOException {
    return asCharSource(url, charset).read();
  }

  /**
   * Streams lines from a URL, stopping when our callback returns false, or we have read all of the
   * lines.

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 129

                @ParametricNullness
  public static <T extends @Nullable Object> T readLines(
      URL url, Charset charset, LineProcessor<T> callback) throws IOException {
    return asCharSource(url, charset).readLines(callback);
  }

  /**
   * Reads all of the lines from a URL. The lines do not include line-termination characters, but do
   * include other leading and trailing whitespace.

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 175

                 * @throws IOException if an I/O error occurs
   */
  public static void copy(URL from, OutputStream to) throws IOException {
    asByteSource(from).copyTo(to);
  }

  /**
   * Returns a {@code URL} pointing to {@code resourceName} if the resource is found using the
   * {@linkplain Thread#getContextClassLoader() context class loader}. In simple environments, the

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 196

                public static URL getResource(String resourceName) {
    ClassLoader loader =
        MoreObjects.firstNonNull(
            Thread.currentThread().getContextClassLoader(), Resources.class.getClassLoader());
    URL url = loader.getResource(resourceName);
    checkArgument(url != null, "resource %s not found.", resourceName);
    return url;
  }


            

Reported by PMD.

In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.
Error

Line: 196

                public static URL getResource(String resourceName) {
    ClassLoader loader =
        MoreObjects.firstNonNull(
            Thread.currentThread().getContextClassLoader(), Resources.class.getClassLoader());
    URL url = loader.getResource(resourceName);
    checkArgument(url != null, "resource %s not found.", resourceName);
    return url;
  }


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 197

                  ClassLoader loader =
        MoreObjects.firstNonNull(
            Thread.currentThread().getContextClassLoader(), Resources.class.getClassLoader());
    URL url = loader.getResource(resourceName);
    checkArgument(url != null, "resource %s not found.", resourceName);
    return url;
  }

  /**

            

Reported by PMD.

guava/src/com/google/common/base/Functions.java
8 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 144

                private static class FunctionForMapNoDefault<
          K extends @Nullable Object, V extends @Nullable Object>
      implements Function<K, V>, Serializable {
    final Map<K, V> map;

    FunctionForMapNoDefault(Map<K, V> map) {
      this.map = checkNotNull(map);
    }


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 183

              
  private static class ForMapWithDefault<K extends @Nullable Object, V extends @Nullable Object>
      implements Function<K, V>, Serializable {
    final Map<K, ? extends V> map;
    @ParametricNullness final V defaultValue;

    ForMapWithDefault(Map<K, ? extends V> map, @ParametricNullness V defaultValue) {
      this.map = checkNotNull(map);
      this.defaultValue = defaultValue;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 184

                private static class ForMapWithDefault<K extends @Nullable Object, V extends @Nullable Object>
      implements Function<K, V>, Serializable {
    final Map<K, ? extends V> map;
    @ParametricNullness final V defaultValue;

    ForMapWithDefault(Map<K, ? extends V> map, @ParametricNullness V defaultValue) {
      this.map = checkNotNull(map);
      this.defaultValue = defaultValue;
    }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 244

                private static class FunctionComposition<
          A extends @Nullable Object, B extends @Nullable Object, C extends @Nullable Object>
      implements Function<A, C>, Serializable {
    private final Function<B, C> g;
    private final Function<A, ? extends B> f;

    public FunctionComposition(Function<B, C> g, Function<A, ? extends B> f) {
      this.g = checkNotNull(g);
      this.f = checkNotNull(f);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 245

                        A extends @Nullable Object, B extends @Nullable Object, C extends @Nullable Object>
      implements Function<A, C>, Serializable {
    private final Function<B, C> g;
    private final Function<A, ? extends B> f;

    public FunctionComposition(Function<B, C> g, Function<A, ? extends B> f) {
      this.g = checkNotNull(g);
      this.f = checkNotNull(f);
    }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 297

                /** @see Functions#forPredicate */
  private static class PredicateFunction<T extends @Nullable Object>
      implements Function<T, Boolean>, Serializable {
    private final Predicate<T> predicate;

    private PredicateFunction(Predicate<T> predicate) {
      this.predicate = checkNotNull(predicate);
    }


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 345

              
  private static class ConstantFunction<E extends @Nullable Object>
      implements Function<@Nullable Object, E>, Serializable {
    @ParametricNullness private final E value;

    public ConstantFunction(@ParametricNullness E value) {
      this.value = value;
    }


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 395

                private static class SupplierFunction<F extends @Nullable Object, T extends @Nullable Object>
      implements Function<F, T>, Serializable {

    private final Supplier<T> supplier;

    private SupplierFunction(Supplier<T> supplier) {
      this.supplier = checkNotNull(supplier);
    }


            

Reported by PMD.

guava/src/com/google/common/graph/EndpointPairIterator.java
8 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 37

               */
@ElementTypesAreNonnullByDefault
abstract class EndpointPairIterator<N> extends AbstractIterator<EndpointPair<N>> {
  private final BaseGraph<N> graph;
  private final Iterator<N> nodeIterator;

  @CheckForNull
  N node = null; // null is safe as an initial value because graphs don't allow null nodes


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 38

              @ElementTypesAreNonnullByDefault
abstract class EndpointPairIterator<N> extends AbstractIterator<EndpointPair<N>> {
  private final BaseGraph<N> graph;
  private final Iterator<N> nodeIterator;

  @CheckForNull
  N node = null; // null is safe as an initial value because graphs don't allow null nodes

  Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 41

                private final Iterator<N> nodeIterator;

  @CheckForNull
  N node = null; // null is safe as an initial value because graphs don't allow null nodes

  Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();

  static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) {
    return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph);

            

Reported by PMD.

Avoid using redundant field initializer for 'node'
Performance

Line: 41

                private final Iterator<N> nodeIterator;

  @CheckForNull
  N node = null; // null is safe as an initial value because graphs don't allow null nodes

  Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();

  static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) {
    return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 43

                @CheckForNull
  N node = null; // null is safe as an initial value because graphs don't allow null nodes

  Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();

  static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) {
    return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph);
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 64

                    return false;
    }
    node = nodeIterator.next();
    successorIterator = graph.successors(node).iterator();
    return true;
  }

  /**
   * If the graph is directed, each ordered [source, target] pair will be visited once if there is

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 120

                 */
  private static final class Undirected<N> extends EndpointPairIterator<N> {
    // It's a little weird that we add `null` to this set, but it makes for slightly simpler code.
    @CheckForNull private Set<@Nullable N> visitedNodes;

    private Undirected(BaseGraph<N> graph) {
      super(graph);
      this.visitedNodes = Sets.newHashSetWithExpectedSize(graph.nodes().size() + 1);
    }

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 146

                      // Add to visited set *after* processing neighbors so we still include self-loops.
        visitedNodes.add(node);
        if (!advance()) {
          visitedNodes = null;
          return endOfData();
        }
      }
    }
  }

            

Reported by PMD.

guava/src/com/google/common/eventbus/Subscriber.java
8 issues
Avoid throwing raw exception types.
Design

Line: 90

                  try {
      method.invoke(target, checkNotNull(event));
    } catch (IllegalArgumentException e) {
      throw new Error("Method rejected target/argument: " + event, e);
    } catch (IllegalAccessException e) {
      throw new Error("Method became inaccessible: " + event, e);
    } catch (InvocationTargetException e) {
      if (e.getCause() instanceof Error) {
        throw (Error) e.getCause();

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 92

                  } catch (IllegalArgumentException e) {
      throw new Error("Method rejected target/argument: " + event, e);
    } catch (IllegalAccessException e) {
      throw new Error("Method became inaccessible: " + event, e);
    } catch (InvocationTargetException e) {
      if (e.getCause() instanceof Error) {
        throw (Error) e.getCause();
      }
      throw e;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 46

                }

  /** The event bus this subscriber belongs to. */
  @Weak private EventBus bus;

  /** The object with the subscriber method. */
  @VisibleForTesting final Object target;

  /** Subscriber method. */

            

Reported by PMD.

Private field 'bus' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 46

                }

  /** The event bus this subscriber belongs to. */
  @Weak private EventBus bus;

  /** The object with the subscriber method. */
  @VisibleForTesting final Object target;

  /** Subscriber method. */

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 49

                @Weak private EventBus bus;

  /** The object with the subscriber method. */
  @VisibleForTesting final Object target;

  /** Subscriber method. */
  private final Method method;

  /** Executor to use for dispatching events to this subscriber. */

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 52

                @VisibleForTesting final Object target;

  /** Subscriber method. */
  private final Method method;

  /** Executor to use for dispatching events to this subscriber. */
  private final Executor executor;

  private Subscriber(EventBus bus, Object target, Method method) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 55

                private final Method method;

  /** Executor to use for dispatching events to this subscriber. */
  private final Executor executor;

  private Subscriber(EventBus bus, Object target, Method method) {
    this.bus = bus;
    this.target = checkNotNull(target);
    this.method = method;

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 118

                    // Use == so that different equal instances will still receive events.
      // We only guard against the case that the same object is registered
      // multiple times
      return target == that.target && method.equals(that.method);
    }
    return false;
  }

  /**

            

Reported by PMD.

guava/src/com/google/common/hash/LongAdder.java
8 issues
This class has too many methods, consider refactoring it.
Design

Line: 42

               * @author Doug Lea
 */
@ElementTypesAreNonnullByDefault
final class LongAdder extends Striped64 implements Serializable, LongAddable {
  private static final long serialVersionUID = 7249069246863182397L;

  /** Version of plus for use in retryUpdate */
  @Override
  final long fn(long v, long x) {

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 66

                  int[] hc;
    Cell a;
    int n;
    if ((as = cells) != null || !casBase(b = base, b + x)) {
      boolean uncontended = true;
      if ((hc = threadHashCode.get()) == null
          || as == null
          || (n = as.length) < 1
          || (a = as[(n - 1) & hc[0]]) == null

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 68

                  int n;
    if ((as = cells) != null || !casBase(b = base, b + x)) {
      boolean uncontended = true;
      if ((hc = threadHashCode.get()) == null
          || as == null
          || (n = as.length) < 1
          || (a = as[(n - 1) & hc[0]]) == null
          || !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);
    }

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 189

                private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();
    busy = 0;
    cells = null;
    base = s.readLong();
  }
}

            

Reported by PMD.

Use one line for each declaration, it enhances code readability.
Design

Line: 62

                @Override
  public void add(long x) {
    Cell[] as;
    long b, v;
    int[] hc;
    Cell a;
    int n;
    if ((as = cells) != null || !casBase(b = base, b + x)) {
      boolean uncontended = true;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'as' (lines '66'-'74').
Error

Line: 66

                  int[] hc;
    Cell a;
    int n;
    if ((as = cells) != null || !casBase(b = base, b + x)) {
      boolean uncontended = true;
      if ((hc = threadHashCode.get()) == null
          || as == null
          || (n = as.length) < 1
          || (a = as[(n - 1) & hc[0]]) == null

            

Reported by PMD.

Found 'DD'-anomaly for variable 'uncontended' (lines '67'-'68').
Error

Line: 67

                  Cell a;
    int n;
    if ((as = cells) != null || !casBase(b = base, b + x)) {
      boolean uncontended = true;
      if ((hc = threadHashCode.get()) == null
          || as == null
          || (n = as.length) < 1
          || (a = as[(n - 1) & hc[0]]) == null
          || !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'uncontended' (lines '68'-'74').
Error

Line: 68

                  int n;
    if ((as = cells) != null || !casBase(b = base, b + x)) {
      boolean uncontended = true;
      if ((hc = threadHashCode.get()) == null
          || as == null
          || (n = as.length) < 1
          || (a = as[(n - 1) & hc[0]]) == null
          || !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);
    }

            

Reported by PMD.

guava/src/com/google/common/base/Equivalence.java
8 issues
The method name and parameter number are suspiciously close to equals(Object)
Error

Line: 329

                 * @since 8.0 (in Equivalences with null-friendly behavior)
   * @since 4.0 (in Equivalences)
   */
  public static Equivalence<Object> equals() {
    return Equals.INSTANCE;
  }

  /**
   * Returns an equivalence that uses {@code ==} to compare values and {@link

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 43

               * The type parameter is <T> rather than <T extends @Nullable> so that we can use T in the
 * doEquivalent and doHash methods to indicate that the parameter cannot be null.
 */
public abstract class Equivalence<T> implements BiPredicate<@Nullable T, @Nullable T> {
  /** Constructor for use by subclasses. */
  protected Equivalence() {}

  /**
   * Returns {@code true} if the given objects are considered equivalent.

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 65

                 * long as neither {@code x} nor {@code y} is modified.
   */
  public final boolean equivalent(@CheckForNull T a, @CheckForNull T b) {
    if (a == b) {
      return true;
    }
    if (a == null || b == null) {
      return false;
    }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 192

                 * @since 10.0
   */
  public static final class Wrapper<T extends @Nullable Object> implements Serializable {
    private final Equivalence<? super T> equivalence;
    @ParametricNullness private final T reference;

    private Wrapper(Equivalence<? super T> equivalence, @ParametricNullness T reference) {
      this.equivalence = checkNotNull(equivalence);
      this.reference = reference;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 193

                 */
  public static final class Wrapper<T extends @Nullable Object> implements Serializable {
    private final Equivalence<? super T> equivalence;
    @ParametricNullness private final T reference;

    private Wrapper(Equivalence<? super T> equivalence, @ParametricNullness T reference) {
      this.equivalence = checkNotNull(equivalence);
      this.reference = reference;
    }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 226

                         */
          @SuppressWarnings("unchecked")
          Equivalence<Object> equivalence = (Equivalence<Object>) this.equivalence;
          return equivalence.equivalent(this.reference, that.reference);
        }
      }
      return false;
    }


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 281

                private static final class EquivalentToPredicate<T>
      implements Predicate<@Nullable T>, Serializable {

    private final Equivalence<T> equivalence;
    @CheckForNull private final T target;

    EquivalentToPredicate(Equivalence<T> equivalence, @CheckForNull T target) {
      this.equivalence = checkNotNull(equivalence);
      this.target = target;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 282

                    implements Predicate<@Nullable T>, Serializable {

    private final Equivalence<T> equivalence;
    @CheckForNull private final T target;

    EquivalentToPredicate(Equivalence<T> equivalence, @CheckForNull T target) {
      this.equivalence = checkNotNull(equivalence);
      this.target = target;
    }

            

Reported by PMD.

guava/src/com/google/common/io/CharSink.java
8 issues
Ensure that resources like this Writer object are closed after use
Error

Line: 98

              
    Closer closer = Closer.create();
    try {
      Writer out = closer.register(openStream());
      out.append(charSequence);
      out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 99

                  Closer closer = Closer.create();
    try {
      Writer out = closer.register(openStream());
      out.append(charSequence);
      out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 100

                  try {
      Writer out = closer.register(openStream());
      out.append(charSequence);
      out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 101

                    Writer out = closer.register(openStream());
      out.append(charSequence);
      out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 162

              
    try (Writer out = openBufferedStream()) {
      while (lines.hasNext()) {
        out.append(lines.next()).append(lineSeparator);
      }
    }
  }

  /**

            

Reported by PMD.

Ensure that resources like this Writer object are closed after use
Error

Line: 181

              
    Closer closer = Closer.create();
    try {
      Writer out = closer.register(openStream());
      long written = CharStreams.copy(readable, out);
      out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
      return written;
    } catch (Throwable e) {
      throw closer.rethrow(e);

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 183

                  try {
      Writer out = closer.register(openStream());
      long written = CharStreams.copy(readable, out);
      out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
      return written;
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 185

                    long written = CharStreams.copy(readable, out);
      out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
      return written;
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }

            

Reported by PMD.

guava/src/com/google/common/cache/CacheLoader.java
8 issues
A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 75

                 *     treated like any other {@code Exception} in all respects except that, when it is caught,
   *     the thread's interrupt status is set
   */
  public abstract V load(K key) throws Exception;

  /**
   * Computes or retrieves a replacement value corresponding to an already-cached {@code key}. This
   * method is called when an existing cache entry is refreshed by {@link
   * CacheBuilder#refreshAfterWrite}, or through a call to {@link LoadingCache#refresh}.

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 99

                 * @since 11.0
   */
  @GwtIncompatible // Futures
  public ListenableFuture<V> reload(K key, V oldValue) throws Exception {
    checkNotNull(key);
    checkNotNull(oldValue);
    return Futures.immediateFuture(load(key));
  }


            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 127

                 *     the thread's interrupt status is set
   * @since 11.0
   */
  public Map<K, V> loadAll(Iterable<? extends K> keys) throws Exception {
    // This will be caught by getAll(), causing it to fall back to multiple calls to
    // LoadingCache.get
    throw new UnsupportedLoadingOperationException();
  }


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 161

              
  private static final class FunctionToCacheLoader<K, V> extends CacheLoader<K, V>
      implements Serializable {
    private final Function<K, V> computingFunction;

    public FunctionToCacheLoader(Function<K, V> computingFunction) {
      this.computingFunction = checkNotNull(computingFunction);
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 203

                              new Callable<V>() {
                  @Override
                  public V call() throws Exception {
                    return loader.reload(key, oldValue).get();
                  }
                });
        executor.execute(task);
        return task;
      }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 219

              
  private static final class SupplierToCacheLoader<V> extends CacheLoader<Object, V>
      implements Serializable {
    private final Supplier<V> computingSupplier;

    public SupplierToCacheLoader(Supplier<V> computingSupplier) {
      this.computingSupplier = checkNotNull(computingSupplier);
    }


            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 239

                 *
   * @since 19.0
   */
  public static final class UnsupportedLoadingOperationException
      extends UnsupportedOperationException {
    // Package-private because this should only be thrown by loadAll() when it is not overridden.
    // Cache implementors may want to catch it but should not need to be able to throw it.
    UnsupportedLoadingOperationException() {}
  }

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 251

                 *
   * @since 11.0
   */
  public static final class InvalidCacheLoadException extends RuntimeException {
    public InvalidCacheLoadException(String message) {
      super(message);
    }
  }
}

            

Reported by PMD.

guava/src/com/google/common/primitives/UnsignedInteger.java
8 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 43

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class UnsignedInteger extends Number implements Comparable<UnsignedInteger> {
  public static final UnsignedInteger ZERO = fromIntBits(0);
  public static final UnsignedInteger ONE = fromIntBits(1);
  public static final UnsignedInteger MAX_VALUE = fromIntBits(-1);

  private final int value;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 43

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class UnsignedInteger extends Number implements Comparable<UnsignedInteger> {
  public static final UnsignedInteger ZERO = fromIntBits(0);
  public static final UnsignedInteger ONE = fromIntBits(1);
  public static final UnsignedInteger MAX_VALUE = fromIntBits(-1);

  private final int value;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 48

                public static final UnsignedInteger ONE = fromIntBits(1);
  public static final UnsignedInteger MAX_VALUE = fromIntBits(-1);

  private final int value;

  private UnsignedInteger(int value) {
    // GWT doesn't consistently overflow values to make them 32-bit, so we need to force it.
    this.value = value & 0xffffffff;
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 127

                 * @since 14.0
   */
  public UnsignedInteger plus(UnsignedInteger val) {
    return fromIntBits(this.value + checkNotNull(val).value);
  }

  /**
   * Returns the result of subtracting this and {@code val}. If the result would be negative,
   * returns the low 32 bits of the result.

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 137

                 * @since 14.0
   */
  public UnsignedInteger minus(UnsignedInteger val) {
    return fromIntBits(value - checkNotNull(val).value);
  }

  /**
   * Returns the result of multiplying this and {@code val}. If the result would have more than 32
   * bits, returns the low 32 bits of the result.

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 149

                @GwtIncompatible // Does not truncate correctly
  public UnsignedInteger times(UnsignedInteger val) {
    // TODO(lowasser): make this GWT-compatible
    return fromIntBits(value * checkNotNull(val).value);
  }

  /**
   * Returns the result of dividing this by {@code val}.
   *

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 159

                 * @since 14.0
   */
  public UnsignedInteger dividedBy(UnsignedInteger val) {
    return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value));
  }

  /**
   * Returns this mod {@code val}.
   *

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 169

                 * @since 14.0
   */
  public UnsignedInteger mod(UnsignedInteger val) {
    return fromIntBits(UnsignedInts.remainder(value, checkNotNull(val).value));
  }

  /**
   * Returns the value of this {@code UnsignedInteger} as an {@code int}. This is an inverse
   * operation to {@link #fromIntBits}.

            

Reported by PMD.