Fix Build Race Condition

One thread could see that the directory was not there
and context switch to another thread that also
doesn't see the directory and creates it. The other
thread would then fail because mkDirs returns
false if the directory exists...

Change-Id: I8fa50acbcaf2637a89cb876e7bc4c544a5c9c1e7
diff --git a/tools/cts-native-xml-generator/src/com/android/cts/nativexml/Generator.java b/tools/cts-native-xml-generator/src/com/android/cts/nativexml/Generator.java
index 3a75e49..7c074b8 100644
--- a/tools/cts-native-xml-generator/src/com/android/cts/nativexml/Generator.java
+++ b/tools/cts-native-xml-generator/src/com/android/cts/nativexml/Generator.java
@@ -59,9 +59,12 @@
         if (mOutputPath != null) {
             File outputFile = new File(mOutputPath);
             File outputDir = outputFile.getParentFile();
-            if (!outputDir.exists() && !outputDir.mkdirs()) {
-                System.err.println("Couldn't make output directory: " + mOutputPath);
-                System.exit(1);
+            if (!outputDir.exists()) {
+                outputDir.mkdirs();
+                if (!outputDir.exists()) {
+                    System.err.println("Couldn't make output directory: " + outputDir);
+                    System.exit(1);
+                }
             }
             output = new FileOutputStream(outputFile);
         }