Author: doogie
Date: Thu Jun 26 16:15:09 2014
New Revision: 1605837
URL:
http://svn.apache.org/r1605837Log:
Fix line-ending differences between windows and unix in UtilIO parsing.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java?rev=1605837&r1=1605836&r2=1605837&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java Thu Jun 26 16:15:09 2014
@@ -382,6 +382,9 @@ public final class UtilIO {
if (buffer[length - 1] == '\n') {
length--;
}
+ if (buffer[length - 1] == '\r') {
+ length--;
+ }
return convertObject(String.class, new String(buffer, i + 1, length - i - 1), type);
}
} catch (Exception e) {
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java?rev=1605837&r1=1605836&r2=1605837&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java Thu Jun 26 16:15:09 2014
@@ -138,6 +138,8 @@ public class UtilIOTests extends Generic
}
protected void checkBasicReadWriteObject(Object value, String text) throws Exception {
+ String lineEnding = System.getProperty("line.separator");
+ text = text.replaceAll("\n", lineEnding);
byte[] bytes = text.getBytes("UTF-8");
assertEquals("read bytes " + value.getClass().getName(), value, UtilIO.readObject(new ByteArrayInputStream(bytes)));
assertEquals("read chars " + value.getClass().getName(), value, UtilIO.readObject(text.toCharArray()));
@@ -147,7 +149,7 @@ public class UtilIOTests extends Generic
assertEquals("write stream " + value.getClass().getName(), text, new String(baos.toByteArray(), "UTF-8"));
StringBuilder sb = new StringBuilder();
UtilIO.writeObject(sb, value);
- sb.append('\n');
+ sb.append(lineEnding);
assertEquals("write builder " + value.getClass().getName(), text, sb.toString());
}