diff --git a/WHATSNEW b/WHATSNEW index 3abb430d7..04fff74ce 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -38,6 +38,9 @@ Fixed bugs: * Ant now fails with a more useful message if a new process will be forked in a directory and that directory doesn't exist. +* used to break the build on non-GUI environments. Bugzilla + report 11482. + Other changes: -------------- * Shipped XML parser is now Xerces-J 2.6.1 diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java index 33c79c0cc..0c21b23b1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2004 Apache Software Foundation + * Copyright 2002-2004 Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ public class SplashTask extends Task { /** * Proxy password; required if user is set. */ - public void setPassword(String password) { + public void setPassword(String password) { this.password = password; } @@ -170,9 +170,9 @@ public class SplashTask extends Task { } } + boolean success = false; if (in != null) { DataInputStream din = new DataInputStream(in); - boolean success = false; try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); int data; @@ -181,10 +181,14 @@ public class SplashTask extends Task { } log("Got ByteArray, creating splash", Project.MSG_DEBUG); - ImageIcon img = new ImageIcon(bout.toByteArray()); - splash = new SplashScreen(img); - success = true; + try { + ImageIcon img = new ImageIcon(bout.toByteArray()); + splash = new SplashScreen(img); + success = true; + } catch (Throwable e) { + logHeadless(e); + } } catch (Exception e) { throw new BuildException(e); } finally { @@ -199,16 +203,28 @@ public class SplashTask extends Task { } } } else { - splash = new SplashScreen("Image Unavailable."); + try { + splash = new SplashScreen("Image Unavailable."); + success = true; + } catch (Throwable e) { + logHeadless(e); + } } - splash.setVisible(true); - splash.toFront(); - getProject().addBuildListener(splash); - try { - Thread.sleep(showDuration); - } catch (InterruptedException e) { + if (success) { + splash.setVisible(true); + splash.toFront(); + getProject().addBuildListener(splash); + try { + Thread.sleep(showDuration); + } catch (InterruptedException e) { + } } + } + private void logHeadless(Throwable e) { + log("failed to display SplashScreen, caught " + + e.getClass().getName() + " with message: " + e.getMessage(), + Project.MSG_WARN); } }