Commits

db_atlass  committed 110e4c6
  • Participants
  • Parent commits aa5a45b
  • Branches detect_fixed_windows_unicode_jvms

Comments (0)

Files changed (1)

File src/main/java/com/atlassian/utils/process/ExternalProcessImpl.java

         return OS_NAME.contains("windows");
     }
 
+    /**
+     *
+     * @return true iff this JVM has a fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4947220.
+     * According to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4947220 &
+     * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=2213209
+     * Sun/Oracle JVM versions 7 & 6u30(and above) do not suffer from 4947220.
+     */
+    private boolean is4947220Fixed() {
+        final String jvmVersion = System.getProperty("java.version");
+        final String jvmVendor = System.getProperty("java.vendor");
+        int minorVersion = -1;
+        if (jvmVersion.split("_").length == 2) {
+            try {
+                minorVersion = Integer.parseInt(jvmVersion.split("_")[1]);
+            }
+            catch (NumberFormatException e) {
+                LOG.error("Failed to parse the JVM minor version", e);
+            }
+        }
+        for (String vendor : Arrays.asList("sun", "oracle", "openjdk")) {
+            if (jvmVendor.toLowerCase(Locale.US).contains(vendor)) {
+               if (jvmVersion.startsWith("1.7")) {
+                   return true;
+               }
+               if (jvmVersion.startsWith("1.6") && minorVersion >= 30) {
+                   return true;
+               }
+            }
+        }
+        return false;
+    }
+
     private String quoteString(String value) {
         StringBuilder builder = new StringBuilder()
                 .append("\"")
 
     protected Process createProcess(List<String> command, Map<String, String> environment, File workingDir)
             throws IOException {
-        if (!suppressSpecialWindowsBehaviour && isWindows()) {
+        if (!suppressSpecialWindowsBehaviour && isWindows() && !is4947220Fixed()) {
             return createWinProcess(command, environment, workingDir);
         } else {
             ProcessBuilder builder = new ProcessBuilder(command).directory(workingDir);