Revision: 3746
http://vexi.svn.sourceforge.net/vexi/?rev=3746&view=rev
Author: mkpg2
Date: 2009-11-04 03:21:54 +0000 (Wed, 04 Nov 2009)
Log Message:
-----------
Fix.
- NPE thrown (in sun code) if urls are bad, handle this.
- Avoid clash (add suffix to log file) if log file is already being used.
Modified Paths:
--------------
trunk/launch/org.vexi.launch/src/org/vexi/launcher/Launcher.java
Modified: trunk/launch/org.vexi.launch/src/org/vexi/launcher/Launcher.java
===================================================================
--- trunk/launch/org.vexi.launch/src/org/vexi/launcher/Launcher.java
2009-11-04 00:29:30 UTC (rev 3745)
+++ trunk/launch/org.vexi.launch/src/org/vexi/launcher/Launcher.java
2009-11-04 03:21:54 UTC (rev 3746)
@@ -235,10 +235,18 @@
protected File createLog(String logfile) throws IOException {
File dir = dotvexi.findSubDir("logs");
dir.mkdirs();
- File f = new File(dir,logfile);
- if ((f.exists() && !f.delete()) || !f.createNewFile())
- throw new RuntimeException("Could not create log file: " +
f.getCanonicalPath());
- return f;
+ File f=null;
+ String fname = logfile;
+ for(int i=0; i<100; i++){
+ f = new File(dir,fname);
+ if ((f.exists() && !f.delete())) {
+ fname = logfile+i;
+ continue; // file occupied!
+ }
+ if(!f.createNewFile()) break;
+ return f;
+ }
+ throw new RuntimeException("Could not create log file: " +
f.getCanonicalPath());
}
public void go() {
@@ -447,11 +455,17 @@
}
static private URLConnection connect(String url) throws IOException{
- URL u = new URL(url);
- final URLConnection uc = u.openConnection();
- uc.setUseCaches(false); // don't use the possibly short Java cache
- uc.connect();
- return uc;
+ try{
+ URL u = new URL(url);
+ final URLConnection uc = u.openConnection();
+ uc.setUseCaches(false); // don't use the possibly short Java
cache
+ uc.connect();
+ return uc;
+ }catch(NullPointerException npe){
+ // WORKAROUND - sun libraries throw a NPE rather than
+ // a more informative exception.
+ throw new IOException("Invalid url: "+url);
+ }
}
//////////////
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn