Browse Source

Make failure to display the splash screen non-fatal.

I've tested this with JDK 1.4 and the java.awt.headless system
property set to true as well as a Unix box running without an X
server.  While the former throws an Exception in the constructor of
SplashScreen, the later throws an Error in the constructor of
ImageIcon.

PR: 11482

Fix a copyright year mistake introduced in revision 1.9 at the same time.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276038 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
918cac2917
2 changed files with 32 additions and 13 deletions
  1. +3
    -0
      WHATSNEW
  2. +29
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java

+ 3
- 0
WHATSNEW View File

@@ -38,6 +38,9 @@ Fixed bugs:
* Ant now fails with a more useful message if a new process will be * Ant now fails with a more useful message if a new process will be
forked in a directory and that directory doesn't exist. forked in a directory and that directory doesn't exist.


* <splash> used to break the build on non-GUI environments. Bugzilla
report 11482.

Other changes: Other changes:
-------------- --------------
* Shipped XML parser is now Xerces-J 2.6.1 * Shipped XML parser is now Xerces-J 2.6.1


+ 29
- 13
src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 <tt>user</tt> is set. * Proxy password; required if <tt>user</tt> is set.
*/ */
public void setPassword(String password) {
public void setPassword(String password) {
this.password = password; this.password = password;
} }


@@ -170,9 +170,9 @@ public class SplashTask extends Task {
} }
} }


boolean success = false;
if (in != null) { if (in != null) {
DataInputStream din = new DataInputStream(in); DataInputStream din = new DataInputStream(in);
boolean success = false;
try { try {
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
int data; int data;
@@ -181,10 +181,14 @@ public class SplashTask extends Task {
} }


log("Got ByteArray, creating splash", Project.MSG_DEBUG); 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) { } catch (Exception e) {
throw new BuildException(e); throw new BuildException(e);
} finally { } finally {
@@ -199,16 +203,28 @@ public class SplashTask extends Task {
} }
} }
} else { } 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);
} }
} }

Loading…
Cancel
Save