-
Notifications
You must be signed in to change notification settings - Fork 17
Fix gradle-baseline excavator #6710
Changes from 7 commits
77b4882
42ac984
b3b311a
f1bae4d
6cd1200
c710083
a1dfcfa
12b449f
bd074de
2c04fc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,16 +53,16 @@ private enum State { | |
| private final Lock lock = new ReentrantLock(false); | ||
| private final Condition condition = lock.newCondition(); | ||
|
|
||
| @GuardedBy(value = "lock") | ||
| @GuardedBy("lock") | ||
| private V returnValue; | ||
|
|
||
| @GuardedBy(value = "lock") | ||
| @GuardedBy("lock") | ||
| private Throwable executionException; | ||
|
|
||
| @GuardedBy(value = "lock") | ||
| @GuardedBy("lock") | ||
| private volatile CancellationException cancellationException; | ||
|
|
||
| @GuardedBy(value = "lock") | ||
| @GuardedBy("lock") | ||
| private volatile State state = State.WAITING_TO_RUN; | ||
|
|
||
| private final FutureTask<?> futureTask = new FutureTask<Void>( | ||
|
|
@@ -113,10 +113,14 @@ public final boolean cancel(boolean mayInterruptIfRunning) { | |
| return futureTask.cancel(mayInterruptIfRunning); | ||
| } | ||
|
|
||
| @SuppressWarnings("GuardedByChecker") | ||
| protected void noteFinished() { | ||
| state = State.COMPLETED; | ||
| condition.signalAll(); | ||
| lock.lock(); | ||
| try { | ||
| state = State.COMPLETED; | ||
| condition.signalAll(); | ||
| } finally { | ||
| lock.unlock(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -157,31 +161,43 @@ public final V get(long timeout, TimeUnit unit) | |
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("GuardedByChecker") | ||
| private V getReturnValue() throws ExecutionException, CancellationException { | ||
| if (cancellationException != null) { | ||
| throw Throwables.chain( | ||
| new CancellationException("This task was canceled before it ever ran."), cancellationException); | ||
| } | ||
| if (executionException != null) { | ||
| throw new ExecutionException(executionException); | ||
| lock.lock(); | ||
|
||
| try { | ||
| if (cancellationException != null) { | ||
| throw Throwables.chain( | ||
| new CancellationException("This task was canceled before it ever ran."), cancellationException); | ||
| } | ||
| if (executionException != null) { | ||
| throw new ExecutionException(executionException); | ||
| } | ||
| return returnValue; | ||
| } finally { | ||
| lock.unlock(); | ||
| } | ||
| return returnValue; | ||
| } | ||
|
|
||
| /** | ||
| * @return true if and only if the task was canceled before it ever executed | ||
| */ | ||
| @Override | ||
| @SuppressWarnings("GuardedByChecker") | ||
| public final boolean isCancelled() { | ||
| return cancellationException != null; | ||
| lock.lock(); | ||
| try { | ||
| return cancellationException != null; | ||
| } finally { | ||
| lock.unlock(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings("GuardedByChecker") | ||
| public final boolean isDone() { | ||
| return state == State.COMPLETED; | ||
| lock.lock(); | ||
| try { | ||
| return state == State.COMPLETED; | ||
| } finally { | ||
| lock.unlock(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -244,10 +244,9 @@ private synchronized boolean isNewEvent(LockWatchEvent event) { | |||||||||||||||||
| .orElse(true); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| @SuppressWarnings("GuardedBy") // The stream operation is terminal within this synchronized method. | ||||||||||||||||||
| private synchronized void assertNoSnapshotsMissing(Multimap<Sequence, StartTimestamp> reversedMap) { | ||||||||||||||||||
| Set<Sequence> sequences = reversedMap.keySet(); | ||||||||||||||||||
| if (sequences.stream().map(snapshotStore::getSnapshotForSequence).anyMatch(Optional::isEmpty)) { | ||||||||||||||||||
| if (sequences.stream().map(this::getSnapshotForSequence).anyMatch(Optional::isEmpty)) { | ||||||||||||||||||
| log.warn( | ||||||||||||||||||
| "snapshots were not taken for all sequences; logging additional information", | ||||||||||||||||||
| SafeArg.of("numSequences", sequences), | ||||||||||||||||||
|
|
@@ -261,6 +260,12 @@ private synchronized void assertNoSnapshotsMissing(Multimap<Sequence, StartTimes | |||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| private Optional<ValueCacheSnapshot> getSnapshotForSequence(Sequence sequence) { | ||||||||||||||||||
| synchronized (this) { | ||||||||||||||||||
| return snapshotStore.getSnapshotForSequence(sequence); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
||||||||||||||||||
| private Optional<ValueCacheSnapshot> getSnapshotForSequence(Sequence sequence) { | |
| synchronized (this) { | |
| return snapshotStore.getSnapshotForSequence(sequence); | |
| } | |
| } | |
| private synchronized Optional<ValueCacheSnapshot> getSnapshotForSequence(Sequence sequence) { | |
| return snapshotStore.getSnapshotForSequence(sequence); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1240,7 +1240,7 @@ private static String escapeText(String input) { | |
| break; | ||
| default: | ||
| // Check for other control characters | ||
| if (c >= 0x0000 && c <= 0x001F) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| if (c <= 0x001F) { | ||
| appendEscapedUnicode(builder, c); | ||
| } else if (Character.isHighSurrogate(c)) { | ||
| // Encode the surrogate pair using 2 six-character sequence (\\uXXXX\\uXXXX) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,13 +165,15 @@ public static boolean isQueryRegistered(String key) { | |
| * @param dbType Look for queries registered with this override first | ||
| * @return a SQLString object representing the stored query | ||
| */ | ||
| @SuppressWarnings("GuardedByChecker") | ||
| static FinalSQLString getByKey(final String key, DBType dbType) { | ||
| assert isValidKey(key) : "Keys only consist of word characters"; // $NON-NLS-1$ | ||
| assert registeredValues.containsKey(key) || registeredValuesOverride.containsKey(key) | ||
| : "Couldn't find SQLString key: " + key + ", dbtype " + dbType; // $NON-NLS-1$ //$NON-NLS-2$ | ||
|
|
||
| FinalSQLString cached = cachedKeyed.get(key); | ||
| FinalSQLString cached; | ||
| synchronized (cacheLock) { | ||
| cached = cachedKeyed.get(key); | ||
|
||
| } | ||
| if (null != cached) { | ||
| callbackOnUse.noteUse((SQLString) cached.delegate); | ||
| return cached; | ||
|
|
@@ -209,7 +211,6 @@ public static boolean isValidKey(final String key) { | |
| * @param sql The string to be used in a query | ||
| * @return a SQLString object representing the given SQL | ||
| */ | ||
| @SuppressWarnings("GuardedByChecker") | ||
| static FinalSQLString getUnregisteredQuery(String sql) { | ||
| assert !isValidKey(sql) : "Unregistered Queries should not look like keys"; // $NON-NLS-1$ | ||
| return new FinalSQLString(new SQLString(sql)); | ||
|
|
@@ -423,9 +424,10 @@ protected static ImmutableMap<String, FinalSQLString> getCachedUnregistered() { | |
| @Deprecated | ||
| protected static void setCachedUnregistered(ImmutableMap<String, FinalSQLString> _cachedUnregistered) {} | ||
|
|
||
| @SuppressWarnings("GuardedByChecker") | ||
| protected static ImmutableMap<String, FinalSQLString> getCachedKeyed() { | ||
| return cachedKeyed; | ||
| synchronized (cacheLock) { | ||
| return cachedKeyed; | ||
| } | ||
| } | ||
|
|
||
| protected static void setCachedKeyed(ImmutableMap<String, FinalSQLString> cachedKeyed) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively I think we can annotate this method with
@GuardedBy("lock")to ensure the lock is already held.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call and simplifies things