[jboss-svn-commits] JBL Code SVN: r8151 - in labs/jbossesb/trunk/product/core/rosetta: src/org/jboss/internal/soa/esb/couriers/helpers src/org/jboss/soa/esb/couriers tests/src/org/jboss/internal/soa/esb/couriers/tests
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Dec 8 15:35:46 EST 2006
Author: estebanschifman
Date: 2006-12-08 15:35:37 -0500 (Fri, 08 Dec 2006)
New Revision: 8151
Modified:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/LocalFileHandler.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java
labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java
Log:
Fix FileCourier and LocalFileHandler to work both in Linux and Windows
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/LocalFileHandler.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/LocalFileHandler.java 2006-12-08 18:35:18 UTC (rev 8150)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/LocalFileHandler.java 2006-12-08 20:35:37 UTC (rev 8151)
@@ -65,7 +65,11 @@
public boolean renameFile(File from, File to) throws CourierException
{
- try { return from.renameTo(to); }
+ try
+ {
+ to.delete();
+ return from.renameTo(to);
+ }
catch (Exception e) {throw new CourierException(e);}
}
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java 2006-12-08 18:35:18 UTC (rev 8150)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java 2006-12-08 20:35:37 UTC (rev 8151)
@@ -128,8 +128,9 @@
,ParserConfigurationException, SAXException
{
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(from));
- Serializable serial = (Serializable)reader.readObject();
- reader.close();
+ Serializable serial = null;
+ try { serial = (Serializable)reader.readObject(); }
+ finally { reader.close(); }
return Util.deserialize(serial);
}
@@ -148,11 +149,17 @@
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buff = new byte[1000];
int iQ = 0;
- while ((iQ=in.read(buff))>=0)
- if (iQ>0)
- out.write(buff,0,iQ);
- in.close();
- out.close();
+ try
+ {
+ while ((iQ=in.read(buff))>=0)
+ if (iQ>0)
+ out.write(buff,0,iQ);
+ }
+ finally
+ {
+ in.close();
+ out.close();
+ }
return out.toByteArray();
}
Modified: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java 2006-12-08 18:35:18 UTC (rev 8150)
+++ labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java 2006-12-08 20:35:37 UTC (rev 8151)
@@ -55,7 +55,8 @@
private static Logger _logger = Logger.getLogger(FileCourierUnitTest.class);
private static final String DEFAULT_TEMP =
(System.getProperty("os.name").toLowerCase().contains("window")) ? "/temp" : "/tmp";
- private static final String TMP_DIR = System.getProperty("java.io.tmpdir",DEFAULT_TEMP);
+// private static final String TMP_DIR = System.getProperty("java.io.tmpdir",DEFAULT_TEMP);
+ private static final String TMP_DIR = DEFAULT_TEMP;
static File _tmpDir = new File(TMP_DIR);
static String TEST_SUFFIX = ".testMessage";
More information about the jboss-svn-commits
mailing list