Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JdkInfo] handle invalid XML from /usr/libexec/java_home #120

Merged
merged 1 commit into from
Jun 4, 2021

Conversation

jonathanpeppers
Copy link
Member

Context: https://dev.azure.com/xamarin/public/_build/results?buildId=40929&view=logs&j=cfef19e4-4225-5e84-636a-86ba2231ac21&t=cd3bc6c3-ac29-5320-67c9-5fb59fc8e05c&l=732

dotnet/maui has hit some build failures such as:

error XARSD7000: System.Xml.XmlException: Root element is missing.
error XARSD7000:   at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <cd2a19182af54ce694ec155c18cdf0fc>:0
error XARSD7000:   at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo (System.String res) [0x00017] in <cd2a19182af54ce694ec155c18cdf0fc>:0
error XARSD7000:   at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x0035d] in <cd2a19182af54ce694ec155c18cdf0fc>:0
error XARSD7000:   at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in <cd2a19182af54ce694ec155c18cdf0fc>:0
error XARSD7000:   at System.Xml.XmlReader.MoveToContent () [0x0003a] in <cd2a19182af54ce694ec155c18cdf0fc>:0
error XARSD7000:   at System.Xml.Linq.XElement.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) [0x0000e] in <7a9b77c9c73b43f99a32b1ba98596ce4>:0
error XARSD7000:   at System.Xml.Linq.XElement.Parse (System.String text, System.Xml.Linq.LoadOptions options) [0x00016] in <7a9b77c9c73b43f99a32b1ba98596ce4>:0
error XARSD7000:   at System.Xml.Linq.XElement.Parse (System.String text) [0x00000] in <7a9b77c9c73b43f99a32b1ba98596ce4>:0
error XARSD7000:   at Xamarin.Android.Tools.JdkInfo+<GetLibexecJdkPaths>d__56.MoveNext () [0x0007e] in <2f2fbe285c184b618ed10818f205c9e8>:0
error XARSD7000:   at System.Linq.Enumerable+DistinctIterator`1[TSource].MoveNext () [0x00028] in <22add0566d954580989fae334638a101>:0
error XARSD7000:   at System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00029] in <22add0566d954580989fae334638a101>:0
error XARSD7000:   at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].ToArray () [0x0003e] in <22add0566d954580989fae334638a101>:0
error XARSD7000:   at System.Linq.Buffer`1[TElement]..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x0000a] in <22add0566d954580989fae334638a101>:0
error XARSD7000:   at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () [0x0001e] in <22add0566d954580989fae334638a101>:0
error XARSD7000:   at System.Linq.Enumerable+ConcatIterator`1[TSource].MoveNext () [0x0002b] in <22add0566d954580989fae334638a101>:0
error XARSD7000:   at System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00029] in <22add0566d954580989fae334638a101>:0
error XARSD7000:   at Xamarin.Android.Tools.AndroidSdkBase.GetValidPath (System.Func`2[T,TResult] pathValidator, System.String ctorParam, System.Func`1[TResult] getPreferredPath, System.Func`1[TResult] getAllPaths) [0x00040] in <2f2fbe285c184b618ed10818f205c9e8>:0
error XARSD7000:   at Xamarin.Android.Tools.AndroidSdkBase.Initialize (System.String androidSdkPath, System.String androidNdkPath, System.String javaSdkPath) [0x00030] in <2f2fbe285c184b618ed10818f205c9e8>:0
error XARSD7000:   at Xamarin.Android.Tools.AndroidSdkInfo..ctor (System.Action`2[T1,T2] logger, System.String androidSdkPath, System.String androidNdkPath, System.String javaSdkPath) [0x00025] in <2f2fbe285c184b618ed10818f205c9e8>:0
error XARSD7000:   at Xamarin.Android.Tasks.MonoAndroidHelper.RefreshAndroidSdk (System.String sdkPath, System.String ndkPath, System.String javaPath, Microsoft.Build.Utilities.TaskLoggingHelper logHelper) [0x00005] in <5a1df33220564ef787578ac3c7e67d03>:0
error XARSD7000:   at Xamarin.Android.Tasks.ResolveSdks.RunTask () [0x000ac] in <5a1df33220564ef787578ac3c7e67d03>:0
error XARSD7000:   at Xamarin.Android.Tasks.AndroidTask.Execute () [0x00000] in <5a1df33220564ef787578ac3c7e67d03>:0

Looking at the method in question, it doesn't handle XmlException
and warn appropriately.

I don't have the actual output of /usr/libexec/java_home from
these machines, but I suspect it's printing some message before the
XML or no XML at all.

Context: https://dev.azure.com/xamarin/public/_build/results?buildId=40929&view=logs&j=cfef19e4-4225-5e84-636a-86ba2231ac21&t=cd3bc6c3-ac29-5320-67c9-5fb59fc8e05c&l=732

dotnet/maui has hit some build failures such as:

    error XARSD7000: System.Xml.XmlException: Root element is missing.
    error XARSD7000:   at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <cd2a19182af54ce694ec155c18cdf0fc>:0
    error XARSD7000:   at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo (System.String res) [0x00017] in <cd2a19182af54ce694ec155c18cdf0fc>:0
    error XARSD7000:   at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x0035d] in <cd2a19182af54ce694ec155c18cdf0fc>:0
    error XARSD7000:   at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in <cd2a19182af54ce694ec155c18cdf0fc>:0
    error XARSD7000:   at System.Xml.XmlReader.MoveToContent () [0x0003a] in <cd2a19182af54ce694ec155c18cdf0fc>:0
    error XARSD7000:   at System.Xml.Linq.XElement.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) [0x0000e] in <7a9b77c9c73b43f99a32b1ba98596ce4>:0
    error XARSD7000:   at System.Xml.Linq.XElement.Parse (System.String text, System.Xml.Linq.LoadOptions options) [0x00016] in <7a9b77c9c73b43f99a32b1ba98596ce4>:0
    error XARSD7000:   at System.Xml.Linq.XElement.Parse (System.String text) [0x00000] in <7a9b77c9c73b43f99a32b1ba98596ce4>:0
    error XARSD7000:   at Xamarin.Android.Tools.JdkInfo+<GetLibexecJdkPaths>d__56.MoveNext () [0x0007e] in <2f2fbe285c184b618ed10818f205c9e8>:0
    error XARSD7000:   at System.Linq.Enumerable+DistinctIterator`1[TSource].MoveNext () [0x00028] in <22add0566d954580989fae334638a101>:0
    error XARSD7000:   at System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00029] in <22add0566d954580989fae334638a101>:0
    error XARSD7000:   at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].ToArray () [0x0003e] in <22add0566d954580989fae334638a101>:0
    error XARSD7000:   at System.Linq.Buffer`1[TElement]..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x0000a] in <22add0566d954580989fae334638a101>:0
    error XARSD7000:   at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () [0x0001e] in <22add0566d954580989fae334638a101>:0
    error XARSD7000:   at System.Linq.Enumerable+ConcatIterator`1[TSource].MoveNext () [0x0002b] in <22add0566d954580989fae334638a101>:0
    error XARSD7000:   at System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00029] in <22add0566d954580989fae334638a101>:0
    error XARSD7000:   at Xamarin.Android.Tools.AndroidSdkBase.GetValidPath (System.Func`2[T,TResult] pathValidator, System.String ctorParam, System.Func`1[TResult] getPreferredPath, System.Func`1[TResult] getAllPaths) [0x00040] in <2f2fbe285c184b618ed10818f205c9e8>:0
    error XARSD7000:   at Xamarin.Android.Tools.AndroidSdkBase.Initialize (System.String androidSdkPath, System.String androidNdkPath, System.String javaSdkPath) [0x00030] in <2f2fbe285c184b618ed10818f205c9e8>:0
    error XARSD7000:   at Xamarin.Android.Tools.AndroidSdkInfo..ctor (System.Action`2[T1,T2] logger, System.String androidSdkPath, System.String androidNdkPath, System.String javaSdkPath) [0x00025] in <2f2fbe285c184b618ed10818f205c9e8>:0
    error XARSD7000:   at Xamarin.Android.Tasks.MonoAndroidHelper.RefreshAndroidSdk (System.String sdkPath, System.String ndkPath, System.String javaPath, Microsoft.Build.Utilities.TaskLoggingHelper logHelper) [0x00005] in <5a1df33220564ef787578ac3c7e67d03>:0
    error XARSD7000:   at Xamarin.Android.Tasks.ResolveSdks.RunTask () [0x000ac] in <5a1df33220564ef787578ac3c7e67d03>:0
    error XARSD7000:   at Xamarin.Android.Tasks.AndroidTask.Execute () [0x00000] in <5a1df33220564ef787578ac3c7e67d03>:0

Looking at the method in question, it doesn't handle `XmlException`
and warn appropriately.

I don't have the *actual* output of `/usr/libexec/java_home` from
these machines, but I suspect it's printing some message before the
XML or no XML at all.
@jonathanpeppers jonathanpeppers requested a review from jonpryor June 2, 2021 22:10
@jonathanpeppers
Copy link
Member Author

After talking with the dotnet/maui team, this was a new pool they just setup.

It probably doesn't have a Java at all, and so /usr/libexec/java_home is probably outputting an empty string?

@jonathanpeppers
Copy link
Member Author

Fixes: dotnet/android#5992

@jonpryor jonpryor merged commit 79e3b97 into dotnet:main Jun 4, 2021
@jonathanpeppers jonathanpeppers deleted the jdkinfo-xmlexception branch June 4, 2021 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants