Adding @SuppressWarnings(NoSynchronizedMethodCheck).

In https://chromium-review.googlesource.com/c/chromium/src/+/750645
Chromium started to use an ErrorProne plugin to discourage synchronized
public methods (an encourage the usage of synchronized blocks).

In order to unblock the Chromium Roll we can suppress these warnings
and decide if we want to align with Chromium on this check or ask
them to make it optional.

More details in the bug.

TBR=magjed@webrtc.org

Bug: webrtc:8491
Change-Id: Ie77a324e54aab44a4f59853959549f1d21f884a0
No-Try: True
Reviewed-on: https://webrtc-review.googlesource.com/20060
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20569}
This commit is contained in:
Mirko Bonadei
2017-11-05 19:35:31 -08:00
committed by Commit Bot
parent 08a9c372df
commit 12251b6386
13 changed files with 164 additions and 0 deletions

View File

@ -55,11 +55,15 @@ public class EglRenderer implements VideoRenderer.Callbacks, VideoSink {
private class EglSurfaceCreation implements Runnable {
private Object surface;
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void setSurface(Object surface) {
this.surface = surface;
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void run() {
if (surface != null && eglBase != null && !eglBase.hasSurface()) {
if (surface instanceof Surface) {

View File

@ -77,6 +77,8 @@ public class ScreenCapturerAndroid
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void initialize(final SurfaceTextureHelper surfaceTextureHelper,
final Context applicationContext, final VideoCapturer.CapturerObserver capturerObserver) {
checkNotDisposed();
@ -96,6 +98,8 @@ public class ScreenCapturerAndroid
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void startCapture(
final int width, final int height, final int ignoredFramerate) {
checkNotDisposed();
@ -115,6 +119,8 @@ public class ScreenCapturerAndroid
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void stopCapture() {
checkNotDisposed();
ThreadUtils.invokeAtFrontUninterruptibly(surfaceTextureHelper.getHandler(), new Runnable() {
@ -140,6 +146,8 @@ public class ScreenCapturerAndroid
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void dispose() {
isDisposed = true;
}
@ -153,6 +161,8 @@ public class ScreenCapturerAndroid
* @param ignoredFramerate ignored
*/
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void changeCaptureFormat(
final int width, final int height, final int ignoredFramerate) {
checkNotDisposed();

View File

@ -70,6 +70,8 @@ public class EglRendererTest {
Bitmap storedBitmap;
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onFrame(Bitmap bitmap) {
if (bitmapReceived) {
fail("Unexpected bitmap was received.");
@ -80,6 +82,8 @@ public class EglRendererTest {
notify();
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized boolean waitForBitmap(int timeoutMs) throws InterruptedException {
final long endTimeMs = System.currentTimeMillis() + timeoutMs;
while (!bitmapReceived) {
@ -92,6 +96,8 @@ public class EglRendererTest {
return true;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized Bitmap resetAndGetBitmap() {
bitmapReceived = false;
return storedBitmap;

View File

@ -40,6 +40,8 @@ public class FileVideoCapturerTest {
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onByteBufferFrameCaptured(
byte[] data, int width, int height, int rotation, long timeStamp) {
// Empty on purpose.
@ -52,11 +54,15 @@ public class FileVideoCapturerTest {
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onFrameCaptured(VideoFrame frame) {
frames.add(frame);
notify();
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized ArrayList<VideoFrame> getMinimumFramesBlocking(int minFrames)
throws InterruptedException {
while (frames.size() < minFrames) {

View File

@ -92,6 +92,8 @@ public class PeerConnectionTest {
this.name = name;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void setDataChannel(DataChannel dataChannel) {
assertNull(this.dataChannel);
this.dataChannel = dataChannel;
@ -99,11 +101,15 @@ public class PeerConnectionTest {
assertNotNull(this.dataChannel);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectIceCandidates(int count) {
expectedIceCandidates += count;
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onIceCandidate(IceCandidate candidate) {
--expectedIceCandidates;
@ -119,16 +125,22 @@ public class PeerConnectionTest {
@Override
public void onIceCandidatesRemoved(IceCandidate[] candidates) {}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void setExpectedResolution(int width, int height) {
expectedWidth = width;
expectedHeight = height;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectFramesDelivered(int count) {
expectedFramesDelivered += count;
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void renderFrame(VideoRenderer.I420Frame frame) {
assertTrue(expectedWidth > 0);
assertTrue(expectedHeight > 0);
@ -138,20 +150,28 @@ public class PeerConnectionTest {
VideoRenderer.renderFrameDone(frame);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectSignalingChange(SignalingState newState) {
expectedSignalingChanges.add(newState);
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onSignalingChange(SignalingState newState) {
assertEquals(expectedSignalingChanges.removeFirst(), newState);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectIceConnectionChange(IceConnectionState newState) {
expectedIceConnectionChanges.add(newState);
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onIceConnectionChange(IceConnectionState newState) {
// TODO(bemasc): remove once delivery of ICECompleted is reliable
// (https://code.google.com/p/webrtc/issues/detail?id=3021).
@ -168,15 +188,21 @@ public class PeerConnectionTest {
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onIceConnectionReceivingChange(boolean receiving) {
System.out.println(name + "Got an ICE connection receiving change " + receiving);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectIceGatheringChange(IceGatheringState newState) {
expectedIceGatheringChanges.add(newState);
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onIceGatheringChange(IceGatheringState newState) {
// It's fine to get a variable number of GATHERING messages before
// COMPLETE fires (depending on how long the test runs) so we don't assert
@ -190,11 +216,15 @@ public class PeerConnectionTest {
assertEquals(expectedIceGatheringChanges.removeFirst(), newState);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectAddStream(String label) {
expectedAddStreamLabels.add(label);
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onAddStream(MediaStream stream) {
assertEquals(expectedAddStreamLabels.removeFirst(), stream.label());
for (AudioTrack track : stream.audioTracks) {
@ -209,11 +239,15 @@ public class PeerConnectionTest {
gotRemoteStreams.add(stream);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectRemoveStream(String label) {
expectedRemoveStreamLabels.add(label);
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onRemoveStream(MediaStream stream) {
assertEquals(expectedRemoveStreamLabels.removeFirst(), stream.label());
WeakReference<VideoRenderer> renderer = renderers.remove(stream);
@ -224,40 +258,56 @@ public class PeerConnectionTest {
gotRemoteStreams.remove(stream);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectDataChannel(String label) {
expectedRemoteDataChannelLabels.add(label);
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onDataChannel(DataChannel remoteDataChannel) {
assertEquals(expectedRemoteDataChannelLabels.removeFirst(), remoteDataChannel.label());
setDataChannel(remoteDataChannel);
assertEquals(DataChannel.State.CONNECTING, dataChannel.state());
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectRenegotiationNeeded() {
++expectedRenegotiations;
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onRenegotiationNeeded() {
assertTrue(--expectedRenegotiations >= 0);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectAddTrack(int expectedTracksAdded) {
this.expectedTracksAdded = expectedTracksAdded;
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams) {
expectedTracksAdded--;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectMessage(ByteBuffer expectedBuffer, boolean expectedBinary) {
expectedBuffers.add(new DataChannel.Buffer(expectedBuffer, expectedBinary));
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onMessage(DataChannel.Buffer buffer) {
DataChannel.Buffer expected = expectedBuffers.removeFirst();
assertEquals(expected.binary, buffer.binary);
@ -265,21 +315,29 @@ public class PeerConnectionTest {
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onBufferedAmountChange(long previousAmount) {
assertFalse(previousAmount == dataChannel.bufferedAmount());
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onStateChange() {
assertEquals(expectedStateChanges.removeFirst(), dataChannel.state());
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectStateChange(DataChannel.State state) {
expectedStateChanges.add(state);
}
// Old getStats callback.
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onComplete(StatsReport[] reports) {
if (--expectedOldStatsCallbacks < 0) {
throw new RuntimeException("Unexpected stats report: " + Arrays.toString(reports));
@ -289,6 +347,8 @@ public class PeerConnectionTest {
// New getStats callback.
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onStatsDelivered(RTCStatsReport report) {
if (--expectedNewStatsCallbacks < 0) {
throw new RuntimeException("Unexpected stats report: " + report);
@ -296,6 +356,8 @@ public class PeerConnectionTest {
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onFirstPacketReceived(MediaStreamTrack.MediaType mediaType) {
if (mediaType == MediaStreamTrack.MediaType.MEDIA_TYPE_AUDIO) {
expectedFirstAudioPacket--;
@ -307,19 +369,27 @@ public class PeerConnectionTest {
}
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectFirstPacketReceived() {
expectedFirstAudioPacket = 1;
expectedFirstVideoPacket = 1;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectOldStatsCallback() {
++expectedOldStatsCallbacks;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectNewStatsCallback() {
++expectedNewStatsCallbacks;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized LinkedList<StatsReport[]> takeStatsReports() {
LinkedList<StatsReport[]> got = gotStatsReports;
gotStatsReports = new LinkedList<StatsReport[]>();
@ -328,6 +398,8 @@ public class PeerConnectionTest {
// Return a set of expectations that haven't been satisfied yet, possibly
// empty if no such expectations exist.
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized TreeSet<String> unsatisfiedExpectations() {
TreeSet<String> stillWaitingForExpectations = new TreeSet<String>();
if (expectedIceCandidates > 0) { // See comment in onIceCandidate.
@ -447,6 +519,8 @@ public class PeerConnectionTest {
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void renderFrame(VideoRenderer.I420Frame frame) {
// Because different camera devices (fake & physical) produce different
// resolutions, we only sanity-check the set sizes,

View File

@ -48,6 +48,8 @@ public class SurfaceTextureHelperTest {
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onTextureFrameAvailable(
int oesTextureId, float[] transformMatrix, long timestampNs) {
if (expectedThread != null && Thread.currentThread() != expectedThread) {
@ -62,6 +64,8 @@ public class SurfaceTextureHelperTest {
/**
* Wait indefinitely for a new frame.
*/
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void waitForNewFrame() throws InterruptedException {
while (!hasNewFrame) {
wait();
@ -73,6 +77,8 @@ public class SurfaceTextureHelperTest {
* Wait for a new frame, or until the specified timeout elapses. Returns true if a new frame was
* received before the timeout.
*/
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized boolean waitForNewFrame(final long timeoutMs) throws InterruptedException {
final long startTimeMs = SystemClock.elapsedRealtime();
long timeRemainingMs = timeoutMs;

View File

@ -134,6 +134,8 @@ public class SurfaceViewRendererOnMeasureTest {
private int frameHeight;
private int rotation;
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void waitForFrameSize(int frameWidth, int frameHeight, int rotation)
throws InterruptedException {
while (this.frameWidth != frameWidth || this.frameHeight != frameHeight
@ -146,6 +148,8 @@ public class SurfaceViewRendererOnMeasureTest {
public void onFirstFrameRendered() {}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onFrameResolutionChanged(
int frameWidth, int frameHeight, int rotation) {
this.frameWidth = frameWidth;