Actually there is an alternative to using @SuppressWarnings for Mockito mocks:
Region<String, String> region = cast(mock(Region.class)); private static <T> T cast(Object object) { return (T) object; } Personally, I'd prefer to see warnings or workarounds like above than see lots of @SuppressWarnings littered throughout our code base. I think it's a smell of bad code. On Fri, May 8, 2020 at 12:44 PM Jacob Barrett <jbarr...@pivotal.io> wrote: > > > > On May 8, 2020, at 12:41 PM, Donal Evans <doev...@pivotal.io> wrote: > > > > Is there a consensus on what constitutes a benign warning? I think the > only > > times I use @SuppressWarnings is in parameterized tests to suppress the > > unused method warning for the parameters method, or for unchecked casts, > as > > below: > > > > PartitionedRegion detailRegion1 = mock(PartitionedRegion.class); > > when(cache.getRegion(regionPath1)).thenReturn(detailRegion1); > > > > where the thenReturn() would complain, since it's expecting to return a > > Region<Object, Object>. > > > > Would these be considered things that could safely just be ignored (and > so > > for which I can turn off inspection), or is the use of @SuppressWarnings > > here warranted? > > This is a legitimate suppression. There is no other way to correct the > dysfunctional nature of Java Generics than to @SuppressWarnings. In this > case though only that statement should be suppressed. > > -Jake > >