From 5d4dac8de66927f065cfae1a75e1642eb289688c Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 31 Jul 2012 20:40:46 +0200 Subject: [PATCH] Notify FS mediator loading failure --- .../openapi/util/io/FileSystemUtil.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java index 1b30774a5e3b..c76e468fb2f5 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java @@ -63,47 +63,50 @@ public class FileSystemUtil { private static Mediator ourMediator = getMediator(); private static Mediator getMediator() { + Throwable error = null; final boolean forceUseNio2 = SystemProperties.getBooleanProperty(FORCE_USE_NIO2_KEY, false); - final String quickTestPath = SystemInfo.isWindows ? "C:\\" : "/"; if (!forceUseNio2) { if (SystemInfo.isWindows) { try { - final Mediator mediator = new IdeaWin32MediatorImpl(); - mediator.getAttributes(quickTestPath); - return mediator; + return check(new IdeaWin32MediatorImpl()); } catch (Throwable t) { - LOG.warn(t); + error = t; } } else if (SystemInfo.isLinux || SystemInfo.isMac || SystemInfo.isSolaris || SystemInfo.isFreeBSD) { try { - final Mediator mediator = new JnaUnixMediatorImpl(); - mediator.getAttributes(quickTestPath); - return mediator; + return check(new JnaUnixMediatorImpl()); } catch (Throwable t) { - LOG.warn(t); + error = t; } } } if (SystemInfo.isJavaVersionAtLeast("1.7") && !"1.7.0-ea".equals(SystemInfo.JAVA_VERSION)) { try { - final Mediator mediator = new Nio2MediatorImpl(); - mediator.getAttributes(quickTestPath); - return mediator; + return check(new Nio2MediatorImpl()); } catch (Throwable t) { - LOG.warn(t); + error = t; } } - // todo: after introducing IdeaWin32 mediator, fail tests at this point, or issue a warning in production + final String message = + "Failed to load filesystem access layer (" + SystemInfo.OS_NAME + ", " + SystemInfo.JAVA_VERSION + ", " + forceUseNio2 + ")"; + LOG.error(message, error); + return new StandardMediatorImpl(); } + private static Mediator check(final Mediator mediator) throws Exception { + final String quickTestPath = SystemInfo.isWindows ? "C:\\" : "/"; + mediator.getAttributes(quickTestPath); + return mediator; + } + @TestOnly static void resetMediator() { ourMediator = getMediator();