31
31
import com .google .devtools .build .lib .actions .cache .VirtualActionInput ;
32
32
import com .google .devtools .build .lib .concurrent .ThreadSafety .ThreadSafe ;
33
33
import com .google .devtools .build .lib .events .Event ;
34
- import com .google .devtools .build .lib .events .Reporter ;
35
34
import com .google .devtools .build .lib .exec .SpawnCache ;
36
35
import com .google .devtools .build .lib .exec .SpawnCheckingCacheEvent ;
37
36
import com .google .devtools .build .lib .exec .SpawnExecutingEvent ;
48
47
import com .google .devtools .build .lib .remote .util .Utils .InMemoryOutput ;
49
48
import com .google .devtools .build .lib .vfs .Path ;
50
49
import java .io .IOException ;
51
- import java .util .HashSet ;
52
50
import java .util .NoSuchElementException ;
53
- import java .util .Set ;
54
- import javax .annotation .Nullable ;
55
51
56
52
/** A remote {@link SpawnCache} implementation. */
57
53
@ ThreadSafe // If the RemoteActionCache implementation is thread-safe.
@@ -66,20 +62,16 @@ final class RemoteSpawnCache implements SpawnCache {
66
62
private final Path execRoot ;
67
63
private final RemoteOptions options ;
68
64
private final boolean verboseFailures ;
69
- @ Nullable private final Reporter cmdlineReporter ;
70
- private final Set <String > reportedErrors = new HashSet <>();
71
65
private final RemoteExecutionService remoteExecutionService ;
72
66
73
67
RemoteSpawnCache (
74
68
Path execRoot ,
75
69
RemoteOptions options ,
76
70
boolean verboseFailures ,
77
- @ Nullable Reporter cmdlineReporter ,
78
71
RemoteExecutionService remoteExecutionService ) {
79
72
this .execRoot = execRoot ;
80
73
this .options = options ;
81
74
this .verboseFailures = verboseFailures ;
82
- this .cmdlineReporter = cmdlineReporter ;
83
75
this .remoteExecutionService = remoteExecutionService ;
84
76
}
85
77
@@ -150,13 +142,13 @@ public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)
150
142
errorMessage = Utils .grpcAwareErrorMessage (e );
151
143
} else {
152
144
// On --verbose_failures print the whole stack trace
153
- errorMessage = Throwables .getStackTraceAsString (e );
145
+ errorMessage = " \n " + Throwables .getStackTraceAsString (e );
154
146
}
155
147
if (isNullOrEmpty (errorMessage )) {
156
148
errorMessage = e .getClass ().getSimpleName ();
157
149
}
158
- errorMessage = "Reading from Remote Cache:\n " + errorMessage ;
159
- report (Event .warn (errorMessage ));
150
+ errorMessage = "Remote Cache: " + errorMessage ;
151
+ remoteExecutionService . report (Event .warn (errorMessage ));
160
152
}
161
153
}
162
154
}
@@ -193,7 +185,7 @@ public void store(SpawnResult result) throws ExecException, InterruptedException
193
185
try (SilentCloseable c = prof .profile ("RemoteCache.checkForConcurrentModifications" )) {
194
186
checkForConcurrentModifications ();
195
187
} catch (IOException | ForbiddenActionInputException e ) {
196
- report (Event .warn (e .getMessage ()));
188
+ remoteExecutionService . report (Event .warn (e .getMessage ()));
197
189
return ;
198
190
}
199
191
}
@@ -223,20 +215,6 @@ private void checkForConcurrentModifications()
223
215
}
224
216
}
225
217
226
- private void report (Event evt ) {
227
- if (cmdlineReporter == null ) {
228
- return ;
229
- }
230
-
231
- synchronized (this ) {
232
- if (reportedErrors .contains (evt .getMessage ())) {
233
- return ;
234
- }
235
- reportedErrors .add (evt .getMessage ());
236
- cmdlineReporter .handle (evt );
237
- }
238
- }
239
-
240
218
@ Override
241
219
public boolean usefulInDynamicExecution () {
242
220
return false ;
0 commit comments