Commit ad95b98
authored
[Xamarin.Android.Build.Tasks] Handle IOException in Aapt2Daemon (#8130)
* [Xamarin.Android.Build.Tasks] Handle IOException in Aapt2Daemon
When cancelling a build on the command line we occasionally
see the following exception.
```
Unhandled exception. System.IO.IOException: Broken pipe
---> System.Net.Sockets.SocketException (32): Broken pipe
at System.IO.Pipes.PipeStream.WriteCore(ReadOnlySpan`1 buffer)
--- End of inner exception stack trace ---
at System.IO.Pipes.PipeStream.WriteCore(ReadOnlySpan`1 buffer)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.WriteLine(String value)
at Xamarin.Android.Tasks.Aapt2Daemon.Aapt2DaemonStart()
at System.Threading.Thread.StartHelper.Callback(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Unhandled exception. System.IO.IOException: Broken pipe
---> System.Net.Sockets.SocketException (32): Broken pipe
at System.IO.Pipes.PipeStream.WriteCore(ReadOnlySpan`1 buffer)
--- End of inner exception stack trace ---
at System.IO.Pipes.PipeStream.WriteCore(ReadOnlySpan`1 buffer)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.WriteLine(String value)
at Xamarin.Android.Tasks.Aapt2Daemon.Aapt2DaemonStart()
at System.Threading.Thread.StartHelper.Callback(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Unhandled exception. System.IO.IOException: Broken pipe
---> System.Net.Sockets.SocketException (32): Broken pipe
at System.IO.Pipes.PipeStream.WriteCore(ReadOnlySpan`1 buffer)
--- End of inner exception stack trace ---
at System.IO.Pipes.PipeStream.WriteCore(ReadOnlySpan`1 buffer)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.WriteLine(String value)
at Xamarin.Android.Tasks.Aapt2Daemon.Aapt2DaemonStart()
at System.Threading.Thread.StartHelper.Callback(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
```
This happens because we are calling `Stream.WriteLine` after the process
has already exited. So lets catch this exception and ignore it.
* use nameof
* Add additional try/catch1 parent 2b1ec45 commit ad95b98
File tree
2 files changed
+19
-7
lines changed- src/Xamarin.Android.Build.Tasks
- Tasks
- Utilities
2 files changed
+19
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| |||
271 | 273 | | |
272 | 274 | | |
273 | 275 | | |
274 | | - | |
275 | | - | |
276 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
277 | 289 | | |
278 | 290 | | |
279 | 291 | | |
| |||
0 commit comments