bodewig 2004/02/06 01:09:10
Modified: . WHATSNEW
src/main/org/apache/tools/ant/taskdefs/optional/splash
SplashTask.java
Log:
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.
Revision Changes Path
1.539 +3 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.538
retrieving revision 1.539
diff -u -r1.538 -r1.539
--- WHATSNEW 6 Feb 2004 00:36:12 -0000 1.538
+++ WHATSNEW 6 Feb 2004 09:09:10 -0000 1.539
@@ -38,6 +38,9 @@
* Ant now fails with a more useful message if a new process will be
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:
--------------
* Shipped XML parser is now Xerces-J 2.6.1
1.13 +29 -13
ant/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
Index: SplashTask.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SplashTask.java 4 Feb 2004 20:37:54 -0000 1.12
+++ SplashTask.java 6 Feb 2004 09:09:10 -0000 1.13
@@ -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 @@
/**
* Proxy password; required if <tt>user</tt> is set.
*/
- public void setPassword(String password) {
+ public void setPassword(String password) {
this.password = password;
}
@@ -170,9 +170,9 @@
}
}
+ 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 @@
}
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 @@
}
}
} 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);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]